title: How to Protect the admin Panel in Laravel 5.2
body: <p>I have created an eCommerace Application which has admin panel and userview( store for products ) , I want admin to access admin panel while other users to access only specific URLs and products details etc. I have installed Authentication to my Application via <code>php artisan make:auth</code> and it is working fine but what I want to do is now apply a filter which will show admin panel to ADMIN only and store will be displayed to other users.</p>
  
  <p>I have declared a Boolean field in my database which will hold value 0 by default for common users and will hold 1 for admins.</p>
  
  <p><strong>Migrations:</strong></p>
  
  <pre><code>Schema::create('users', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('name');
              $table-&gt;string('email')-&gt;unique();
              $table-&gt;string('password', 60);
              $table-&gt;boolean('admin')-&gt;default(0);
              $table-&gt;rememberToken();
              $table-&gt;timestamps();
  });
  </code></pre>
  
  <p><strong>AuthController:</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\Auth;
  
  use App\User;
  use Validator;
  use App\Http\Controllers\Controller;
  use Illuminate\Foundation\Auth\ThrottlesLogins;
  use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
  
  class AuthController extends Controller
  {
      /*
      |--------------------------------------------------------------------------
      | Registration &amp; Login Controller
      |--------------------------------------------------------------------------
      |
      | This controller handles the registration of new users, as well as the
      | authentication of existing users. By default, this controller uses
      | a simple trait to add these behaviors. Why don't you explore it?
      |
      */
  
      use AuthenticatesAndRegistersUsers, ThrottlesLogins;
  
      /**
       * Where to redirect users after login / registration.
       *
       * @var string
       */
      protected $redirectTo = '/home';
  
      /**
       * Create a new authentication controller instance.
       *
       * @return void
       */
      public function __construct()
      {
          $this-&gt;middleware('guest', ['except' =&gt; 'logout']);
      }
  
      /**
       * Get a validator for an incoming registration request.
       *
       * @param  array  $data
       * @return \Illuminate\Contracts\Validation\Validator
       */
      protected function validator(array $data)
      {
          return Validator::make($data, [
              'name' =&gt; 'required|max:255',    /**
       * Create a new user instance after a valid registration.
       *
       * @param  array  $data
       * @return User
       */
      protected function create(array $data)
      {
          return User::create([
              'name' =&gt; $data['name'],
              'email' =&gt; $data['email'],
              'password' =&gt; bcrypt($data['password']),
          ]);
      }
  }
  
              'email' =&gt; 'required|email|max:255|unique:users',
              'password' =&gt; 'required|confirmed|min:6',
          ]);
      }
  </code></pre>