title: Restrict login if user is disabled in Laravel not working quite well
body: <p>I'm trying to make simple admin function to disable/enable users rather than delete them. </p>
  
  <p>So far I have admin function which successfully update table users and change the status to 0(enabled) and 1(disabled). </p>
  
  <p>Now I have problems when user trying to log and checking his status.</p>
  
  <p>This is my function for login in <code>UserController.php</code></p>
  
  <pre><code>public function loginSubmit() {     
  
      $user = User::where('username', Input::get('username'))-&gt;first();
      if (!$user) {
          $validator-&gt;messages()-&gt;add('username', 'Invalid login or password.');
          return Redirect::to('/users/login')-&gt;withErrors($validator-&gt;errors())-&gt;withInput(Input::except(['captcha']));
      }
  
      $user = User::where('is_disabled', 0)-&gt;first();
      if ($user-&gt;is_disabled == 1) {
          $validator-&gt;messages()-&gt;add('username', 'User not found.');
          return Redirect::to('/users/login')-&gt;withErrors($validator-&gt;errors())-&gt;withInput(Input::except(['captcha']));
      }       
  
      $user-&gt;last_login = \Carbon\Carbon::now();
      $user-&gt;save();
      Session::put('user', ['user_id' =&gt; $user-&gt;user_id]);
  
      return Redirect::to('/');
  }
  </code></pre>
  
  <p>The problem is that when the condition is true <code>($user-&gt;is_disabled == 1)</code> it is logged me in with the next user from table e.g. first user which is is_disabled = 0. </p>
  
  <p>How can I make this in proper way?</p>