문제

How to generate migrations with camelCase code?

Like If migrate users table in camelCase but "$table->timestamps()" return "created_at" & "updated_at" but I want both of them to be named "createdAt" & "updatedAt".

public function up()
{
   Schema::create('users', function($table){
      $table->increments('userId');
      $table->string('userName');
      $table->string('userPassword');
      $table->timestamps();
   });
}
도움이 되었습니까?

해결책

You may use (add both fields manually)

$table->timestamp('createdAt');
$table->timestamp('updatedAt');

Instead of timestamps() and this is just a way to do the task manually while timestamps() do it automatically for you.

Read more on Schema Builder.

다른 팁

You can use

$table->timestamp('createdAt');

and

$table->timestamp('updatedAt');

to table field.

reference: http://laravel.com/docs/schema#adding-columns

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top