laravel eloquent findOrFail code example
Example 1: laravel findorfail
$model = App\Flight::where('name', 'Mike')->firstOrFail();
Example 2: find or fail laravel
$model = App\Models\Flight::findOrFail(1);
$model = App\Models\Flight::where('legs', '>', 100)->firstOrFail();
Example 3: laravel fillable
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'title',
'slug',
'body',
'image',
'published',
'comments_open'
];
Example 4: larave Soft Deletes
Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
});