laravel hasmany and belongsTo relationship
Database 1.user_role_id company address 2.users id name email 3.user_role id role UserController use App\Models\ Userdetails ; $resultadmin = Userdetails ::with([' users ', ' userrole '])->get()->toArray(); Userdetails Model public function users(){ return $this->hasOne('App\Models\users', 'id', 'user_id'); } public function userrole(){ return $this->hasOne('App\Models\Userrole', 'id', 'user_role_id'); } Users Model public function userdetails(){ return $this->belongsTo('App\Models\Userdetails', 'id', 'user_id'); } Userrole Model public function userdetails(){ return $this->belongsTo('App\Models\Userdetails', 'id', 'user_role_id'); } More details get auth user details use Illuminate\Suppor...