“Laravel TimeStamp” Ответ

Laravel Foreign Key

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

Ларавел миграционный откат

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

ЛАРАВЕЛЬНАЯ ВРЕМЯ ВРЕМЕНИ

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

Laravel Drop Column

// 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-Time-Local Laravel Migration Data Data

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

Ответы похожие на “Laravel TimeStamp”

Вопросы похожие на “Laravel TimeStamp”

Больше похожих ответов на “Laravel TimeStamp” по PHP

Смотреть популярные ответы по языку

Смотреть другие языки программирования