currently I want to update my existing table by adding new column. Let's say the column name is is_active
with default value is true. I create new migrations for this.
Then I want to update specific item within this table so the is_active
column is changed to false. How to do this without doing this directly to the database so my teammate can also get this changes?
Should I create new seeder and call it within my migration?
CodePudding user response:
You have to make query to update your is_active
for specific column something like this:
Model::where('id', $id)->update(['is_active' => 'false']);
CodePudding user response:
Use migrations to add a column to your table:
Schema::table('your_table', function (Blueprint $table) {
$table->boolean('is_active');
});
Then you can update the values of the selected items on your Model:
YourModel::where('id', $id)
->update(['is_active' => 'false']);