vendredi 17 juin 2016

Laravel 5, change value in database

I have an Enum field in my database with two options. Active and Inactive.

I allready have all the products I want to edit.

$products= Products::whereIn('id', $arr['id'])->get();
                foreach($products as $product)
                {
                      //
                }

The enum column field in my database is called 'status' and also is written in my Model fillable section. Currently all the products in my $products variable have the 'active' status. Now I want to change the status from active to inactive.

I also have no clue how I can do that. I never worked with Enum fields and just found methods like DB::statement('sql code here'). Isn't there a other way for just simply change the value of the status field?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire