Method to set the default value for current timestamp

You can use useCurrent() method for your custom timestamp column to store the current timestamp as a default value.

1Schema::create('posts', function (Blueprint $table) {
2 $table->id();
3 $table->string('title');
4 $table->timestamp('added_at')->useCurrent();
5 $table->timespamps();
6});

Tip given by @iamgurmandeep

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord