i'm having a bit of a problem with Laravel 5 and Eloquent. I have 3 models userInfo, tasksAssign, and taskCreated. The User model:
public function tasksAssign()
{
return $this->hasMany('App\Tasks', 'fk_user_id_assign', 'id')->where('status', 2);
}
public function tasksCreated()
{
return $this->hasMany('App\Tasks', 'fk_user_id_created', 'id');
}
The tasks model
public function userInfo()
{
return $this->belongsTo('App\User');
//return $this->hasOne('App\User', 'id', 'id'); The hasOne here is just me testing diffrent stuff to see if i could get it to work.
}
Shoulndt i be able to get the value from my User (WHERE id = id in the URL) to show up in my tasks show view with the belongsTo()? like so: {{$tasks->userInfo->name}}
or am i totally off here?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire