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);
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Model;
6
7class Flight extends Model
8{
9 //
10}
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Model;
6
7class Flight extends Model
8{
9 /**
10 * The primary key associated with the table.
11 *
12 * @var string
13 */
14 protected $primaryKey = 'flight_id';
15}
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Model;
6
7class Flight extends Model
8{
9 /**
10 * Indicates if the model should be timestamped.
11 *
12 * @var bool
13 */
14 public $timestamps = false;
15}