Answers for "mass update laravel"

PHP
1

Laravel eloquent mass update

Flight::where('active', 1)
      ->where('destination', 'San Diego')
      ->update(['delayed' => 1]);
Posted by: Guest on July-24-2021
1

eloquent firstOrCreate

firstOrCreate() will automatically create a new entry in the database if there is not match found. Otherwise it will give you the matched item.
firstOrNew() will give you a new model instance to work with if not match was found, but will only be saved to the database when you explicitly do so (calling save() on the model). Otherwise it will give you the matched item.
Posted by: Guest on November-08-2020
0

laravel mass update relationship

$channel->videos()->update(['visibility' => true]);
Posted by: Guest on April-16-2020

Browse Popular Code Answers by Language