Answered by : alberto-peripolli
$affected = DB::table('users') ->where('id', 1) ->update(['votes' => 1]);
Source : https://laravel.com/docs/7.x/queries#updates | Last Update : Thu, 14 May 20
Answered by : disturbed-dunlin-ahrngsgb7mgb
$res=User::where('id',$id)->delete();
Source : https://stackoverflow.com/questions/45458074/laravel-eloquent-orm-delete-method | Last Update : Thu, 12 Nov 20
Answered by : monodeep-roy
DB::table('user')->where('email', $userEmail)->update(array('member_type' => $plan));
Source : https://stackoverflow.com/questions/27248753/laravel-update-query | Last Update : Thu, 26 Nov 20
Answered by : snippets
DB::table('users') ->where('id', $id) ->update([ 'status' => 1 ]);
Source : | Last Update : Wed, 01 Sep 21
Answered by : fragile-fish-2yrot00fv0m2
$user = User::updateOrCreate(['name' => request()->name], [ 'foo' => request()->foo
]);
Source : https://laracasts.com/discuss/channels/laravel/inserting-if-record-not-exist-updating-if-exist?page=1 | Last Update : Fri, 10 Apr 20
Answered by : wandering-wryneck-a7zjwm5h8p5v
DB::table('users')->chunk(100, function($users)
{ foreach ($users as $user) { // }
});
Source : https://laravel.com/docs/5.0/queries | Last Update : Sun, 27 Sep 20
Answered by : fragile-falcon-z57wtdmn31e2
$update = \DB::table('student') ->where('id', $data['id']) ->limit(1) ->update( [ 'name' => $data['name'], 'address' => $data['address'], 'email' => $data['email'], 'contactno' => $data['contactno'] ]);
Source : https://stackoverflow.com/questions/27248753/laravel-update-query | Last Update : Sat, 16 Jan 21
Answered by : suhail-khan
return Destination::orderByDesc( Flight::select('arrived_at') ->whereColumn('destination_id', 'destinations.id') ->orderBy('arrived_at', 'desc') ->limit(1)
)->get();
Source : https://laravel.com/docs/8.x/eloquent | Last Update : Thu, 15 Oct 20