Question

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();
   });
}
Was it helpful?

Solution

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.

OTHER TIPS

You can use

$table->timestamp('createdAt');

and

$table->timestamp('updatedAt');

to table field.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top