findorfail laravel 7 code example
Example 1: laravel findorfail
$model = App\Flight::where('name', 'Mike')->firstOrFail();
Example 2: laravel update from query
$affected = DB::table('users')
->where('id', 1)
->update(['votes' => 1]);
Example 3: laravel eloquent get first
$user = App\User::where('id',$id)->first();
$userId = App\User::where(...)->pluck('id');
Example 4: laravel query with trashed
$user->roles()->withTrashed()->get();
Example 5: laravel eloquent fill
$flight->fill(['name' => 'Flight 22']);