我有一个属于Shipment Model
的Package Model
。我这样设置关系
class Package extends Model
{
public function shipment(){
return $this->belongsTo(Shipment::class,'shipment_id','id');
}
}
一切都在localhost
中正常工作,但是当我将其部署到heroku
时,它向我显示错误
Trying to get property 'date' of non-object
ErrorException
in /app/app/Http/Resources/Package.php (line 19)
'shipment_date'=> $this->shipment->date
你可以试试这个
$this->shipment['date']