1/**
2* The attributes that are mass assignable.
3*
4* @var array
5*/
6public function index()
7{
8 $id = User::insertGetId(
9 ['email' => 'john@example.com','name' => 'john']
10 );
11}
1/**
2* The attributes that are mass assignable.
3*
4* @var array
5*/
6public function index()
7{
8 $id = DB::table('users')->insertGetId(
9 ['email' => 'john@example.com','name' => 'john']
10 );
11}
1// Retrieve a model by its primary key...
2$flight = App\Models\Flight::find(1);
3
4// Retrieve the first model matching the query constraints...
5$flight = App\Models\Flight::where('active', 1)->first();
6
7// Shorthand for retrieving the first model matching the query constraints...
8$flight = App\Models\Flight::firstWhere('active', 1);