Eloquent Relationship
I want to get data of three table which related each other. User Files Folder user create folder and upload many files and also user upload single file Table structure User id ,name Files id,name Folder id ,name,user_id UserFilesFolder(pivot ) user_id,files_id,folder_id function for data getting public function index(){ $id=Auth::user()->id; $data= User::with('userfolder')->where('id',$id)->get(); return view('test',['data'=>$data]); } User Model public function userfolder(){ return $this->hasMany(Folder::class); } Folder Model public function users(){ return $this->belongsTo(User::class); } Files Model public function folders(){ return $this->belongsTo(Folder::class); } Can anyone correct me or guide me correct relations by which I will get right data output?
Please or to participate in this conversation.