There is a championship_user
pivot table:
I get the User
's Championship
data like this:
public function championships() { return $this->belongsToMany(Championship::class)->withPivot('skill_id', 'role', 'result'); }
In the controller, I need to get all the user's Championship
:
$championships = Auth::user()->championships(); $skills = Skill::all(); dd($championships);
The output of dd()
is:
#related: Championship {#236 ▼ #hidden: [] #guarded: [] #connection: "mysql" #table: null #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: false +wasRecentlyCreated: false #attributes: [] #original: [] #changes: [] #casts: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: [] #touches: [] +timestamps: true #visible: [] #fillable: [] }
Those. he cannot find any records, although there are records:
What could be the error? How to fix?