“Laravel Timestamp” Code-Antworten

Laravel Fremdschlüssel

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
OR
Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained();
});
Courageous Cod

Laravel Migration Rollback

To rollback one step:

php artisan migrate:rollback

To rollback multiple steps:

php artisan migrate:rollback --step=[x]
  
To drop all tables and reload all migrations:

php artisan migrate:fresh
Angry Albatross

Laravel Stromstempel

use Carbon\Carbon;
$current_date_time = Carbon::now()->toDateTimeString(); // Produces something like "2019-03-11 12:25:00"
Outrageous Okapi

Laravel Drop -Säule

// To drop a column, use the dropColumn method on the schema builder.
// Before dropping columns from a SQLite database, you will need to add
// the doctrine/dbal dependency to your composer.json file and run the
// composer update command in your terminal to install the library:

Schema::table('users', function (Blueprint $table) {
    $table->dropColumn('votes');
});
Yingfufu

Laravel Timestamp

use Carbon\Carbon;
$current_timestamp = Carbon::now()->timestamp; // Produces something like 1552296328
Borma

datetime-lokaler Laravel-Migrationsdatentyp

public function getDateStartAttribute($value)
{
    return Carbon::parse($value)->format('Y-m-d\TH:i');
}

public function getDateEndAttribute($value)
{
    return Carbon::parse($value)->format('Y-m-d\TH:i');
}
Unsightly Unicorn

Ähnliche Antworten wie “Laravel Timestamp”

Fragen ähnlich wie “Laravel Timestamp”

Weitere verwandte Antworten zu “Laravel Timestamp” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen