I have a very simple Eloquent Model:
class HelpdeskComment extends Model
{
protected $table = 'helpdesk_comment';
protected $guarded = ['id', 'helpdesk_topic_id'];
public function topic () {
return $this->hasOne ('\\App\\Model\\HelpdeskTopic');
}
public function user () {
return $this->hasOne ('\\App\\Model\\User');
}
}
This all works quite well when doing stuff like
$user = $helpdeskComment->user;
However, I would like to change the model so that the User table (specifically the "username" field) is always left-joined against the HelpdeskComment table, regardless of the query function called. Is there a simple/central way to achieve this or do I have to override each function (all(), etc.)?
Thanks for any ideas & pointers.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/21mCkEg
via IFTTT
Aucun commentaire:
Enregistrer un commentaire