Md. Harun Or Rashid
Md. Harun Or Rashid

Reputation: 2180

Adding a default value to a column while creating table in laravel 5.2

I want to add a default value to a column while creating a migration.

How can I do this? Help me please.

Upvotes: 2

Views: 2884

Answers (3)

Manil Batra
Manil Batra

Reputation: 163

->default($value) 

is what you need.

Specify a "default" value for the column. Like

$table->boolean('is_verified')->default(0);

Hope this helps!

Upvotes: 4

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

Add ->default($value) to your clause, for example:

$table->text('description')->default('There is no description yet');

https://laravel.com/docs/5.2/migrations#writing-migrations

Upvotes: 1

Prashant Shukla
Prashant Shukla

Reputation: 261

follow this Faker link. here You can create and initialize a faker generator, which can generate data by accessing properties named after the type of data you want.

Upvotes: 0

Related Questions