find by id laravel eloquent code example
Example 1: laravel find by
$flight = App\Flight::find(1);
$flight = App\Flight::where('active', 1)->first();
$flight = App\Flight::firstWhere('active', 1);
Example 2: laravel eloquent get first
$user = App\User::where('id',$id)->first();
$userId = App\User::where(...)->pluck('id');
Example 3: laravel update
<!-mass update-->
App\Models\Flight::where('active', 1)
->where('destination', 'San Diego')
->update(['delayed' => 1]);
Example 4: laravel update
$flight = App\Models\Flight::find(1);
$flight->name = 'New Flight Name';
$flight->save();
Example 5: laravel eloquent fill
$flight->fill(['name' => 'Flight 22']);