Answer the question
In order to leave comments, you need to log in
BelongsTo takes only the id of the post, why?
Good afternoon. I ran into a problem that I don't quite understand.
There is a standard table of users.
There is a table of tasks where the user id is in the "user" field.
public function user()
{
return $this->belongsTo('App\User', 'user');
}
$task = TaskHistory::where('id', $id)->firstOrFail();
$user = $task->user->name;
$task->user
, it will display the ID. I tried to change a lot of things, according to the advice in Google, but I never came to the right option. Where did I go wrong? Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question