How to check eloquent relationship

     

So i need to check for existing relationship inside the User model and make if statement to give route access to user who has Company relationship.


User.php


public function company(){   return $this->belongsTo('AppCompany' 'user_id');  }  

Company.php


public function user(){   return $this->hasMany('AppUser') ;  }  

ListingController.php


public function create(User $user){   if(count($user->company) > 0){   return view('listings.create');   } else{   return redirect()->back();   }  }  

Navigation view


@inject('user'