Answer the question
In order to leave comments, you need to log in
Why is the id of the related table displayed instead of the record id?
Why are id and category_id the same? Everything is fine in the database, the id records are in the correct order and the values are different there.
public function getUser(Request $request)
{
$user = User::where('steamid',$request->name)->first();
$category = $this->getCategoryUser($user->id);
return view('layouts/panel', compact('user','category'));
}
public function getCategoryUser($id)
{
$category = User::find($id)->category;
return $category;
}
Answer the question
In order to leave comments, you need to log in
Decision.
Add pivot to User model:
Call to view in a loop:$var->pivot->id
Where is the code?
If you enter another table as a join, then at the output the porridge is obtained from the fields.
It is necessary to specify explicitly in select () what and from where you need to select so that the fields do not overlap each other.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question