laravel model functions code example
Example 1: laravel findorfail
$model = App\Flight::where('name', 'Mike')->firstOrFail();
Example 2: laravel delete where
DB::table('users')->where('id', $id)->delete();
Example 3: laravel eloquent fill
$flight->fill(['name' => 'Flight 22']);
Example 4: laravel find query
<?php
$flights = App\Models\Flight::all();
foreach ($flights as $flight) {
echo $flight->name;
}
Example 5: laravel find query
php artisan make:model Flight --migration
php artisan make:model Flight -m