I am trying to get the id of the relations I have setup.
Plate model
public function plateContainer()
{
return $this->belongsTo('App\Models\PlateContainer');
}
PlateContainer Model
public function plate()
{
return $this->hasMany('App\Models\Plate');
}
public function equipmentStatusCode()
{
return $this->hasOne('App\Models\EquipmentStatusCode');
}
EquipmentStatusCode Model
public function plateContainer()
{
return $this->belongsTo('App\Models\PlateContainer');
}
When I try.
$p = Plate::findOrFail(4);
$p->plateContainer->equipmentStatusCode;
return $p;
I get Trying to get property of non-object
. What I am doing wrong?