belongsTo('App\Owner','owner_id','id'); } public function processMethod(){ return $this->belongsTo('App\ProcessMethod','process_method_id','id'); } public function commodity(){ return $this->belongsTo('App\Commodity','commodity_id','id'); } public function tutorials(){ return $this->belongsToMany('App\Tutorial','process_tutorial','process_id','tutorial_id'); } public function getOwnerNameAttribute() { return $this['owner']? $this['owner']['name']:null; } public function getProcessMethodNameAttribute() { return $this['processMethod']? $this['processMethod']['name']:null; } public function getCommodityNameAttribute() { return $this['commodity']? $this['commodity']['name']:null; } public function getCommodityBarcodeAttribute() { return $this['commodity']? $this['commodity']['barcode']:null; } }