Laravel 4 -- Set Current Date as Default in a migration file
I need a column in a database table that should default to the current date. I need this column despite there being a "created_at" column because while it should default to the current date, it has to be modifiable.
I tried $table->date('app_date')->default(now()) but that wasn't pretty.
@chrisgeary92, both options created a "[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'app_date'".
I know this is a very old post but this will not work as expected because the date is hardcoded. It will set the same default date (i.e: 2020-03-12) for every new row (because it's the day when the migration was executed, returned by Carbon).
The correct way to do that is by using a datetime column or to make sure the column is filled everytime with current date from PHP.