belongsTo('\App\Models\License', 'license_id'); } public function user() { return $this->belongsTo('\App\Models\User', 'assigned_to')->withTrashed(); } public function asset() { return $this->belongsTo('\App\Models\Asset', 'asset_id')->withTrashed(); } public function location() { if (($this->user) && ($this->user->location)) { return $this->user->location; } elseif (($this->asset) && ($this->asset->location)) { return $this->asset->location; } return false; } }