title: object of class illuminate database eloquent collection could not be converted to int
body: <p>I am accessing the user table attribute 'role' and want to check if role is 2 then show dashboard but getting this error.
  here is my code</p>
  
  <pre><code>protected $casts = [
      'role' =&gt; 'integer',
  ];
  </code></pre>
  
  <p>here is my controller function where I am accessing the user role column value. it returns the value in array but I want to compare it with an integer value '2'. </p>
  
  <pre><code>public function postSignIn(Request $request)
  {
      $this-&gt;validate($request,[
          'email' =&gt; 'required',
          'password' =&gt; 'required',
      ]);
      $posts = Post::all();
      $email = $request['email'];
      $user = User::where("email",$email)-&gt;get(['role']);
      if(Auth:: attempt(['email' =&gt; $request['email'] , 'password' =&gt; $request['password']]))
      {
          if ($user == 2) {
              return view('admin.dashboard');
  
          }
          else {
              return view('frontend.layouts.user_login_layout', compact('posts'));
          }
      }else{
          return "wrong User";
      }
  }
  </code></pre>