M
Size: a a a
M
AS
ЮМ
class Flight extends Model{
public function airport(){
return $this->hasOne('App\Airport','code','airport_from');
}
}
$flights = Flight::with('airport')->get();
foreach ($flights as $flight){
dump($flight->airport->name);
}
$flights = Flight::all();
foreach ($flights as $flight){
$flight->airport()->get();
dump($flight->airport->name);
}
RK
ЮМ
AS
RK
AS
AS
RK
RK
AS
S🚀
S🚀
Trying to get property of non-object
AS
S🚀
class Flight extends Model{
public function airport(){
return $this->hasOne('App\Airport','code','airport_from');
}
}
$flights = Flight::with('airport')->get();
foreach ($flights as $flight){
dump($flight->airport->name);
}
$flights = Flight::all();
foreach ($flights as $flight){
$flight->airport()->get();
dump($flight->airport->name);
}
RK
M
S🚀
M