laravel update

Solutions on MaxInterview for laravel update by the best coders in the world

showing results for - "laravel update"
Mateo
13 Apr 2016
1//if there is id => 1 for user role , update this and if there is not 
2//id => 1 create it and insert some data for it
3 $data = $request->all();
4   UserRule::updateOrCreate(
5            ['id' => 1],
6            $data
7        );
Filippo
27 Feb 2017
1Page::where('id', $id)->update(array('image' => 'asdasd'));
Anna
29 Oct 2017
1// Retrieve flight by name, or create it if it doesn't exist...
2$flight = App\Flight::firstOrCreate(['name' => 'Flight 10']);
3
4// Retrieve flight by name, or create it with the name, delayed, and arrival_time attributes...
5$flight = App\Flight::firstOrCreate(
6    ['name' => 'Flight 10'],
7    ['delayed' => 1, 'arrival_time' => '11:30']
8);
9
10// Retrieve by name, or instantiate...
11$flight = App\Flight::firstOrNew(['name' => 'Flight 10']);
12
13// Retrieve by name, or instantiate with the name, delayed, and arrival_time attributes...
14$flight = App\Flight::firstOrNew(
15    ['name' => 'Flight 10'],
16    ['delayed' => 1, 'arrival_time' => '11:30']
17);
Elena
17 Aug 2019
1php composer.phar update
Alex
05 Jan 2021
1$user = User::updateOrCreate(['name' => request()->name], [ 
2    'foo' => request()->foo
3]);
4
Alex
17 Jan 2016
1$flight = App\Models\Flight::find(1);
2
3$flight->name = 'New Flight Name';
4
5$flight->save();
similar questions
queries leading to this page
laravel update