title: Manage multiple Role in laravel
body: <p>I have created a roles and group table following things:</p>
  
  <p>Group : Car
  Role : Owner,Customer,Agent.</p>
  
  <p>I have table where I include above things :</p>
  
  <p>Group table</p>
  
  <p>Role table </p>
  
  <p>Role Group Mapping table</p>
  
  <p>I have login screen in laravel default I just change a login layout using show_login() override a method. I want to implement role base login. Views are restricted to role (Owner,Agent,Customer).</p>
  
  <p>Login Controller:</p>
  
  <pre><code>&lt;?php
  namespace App\Http\Controllers\Auth;
  
  use App\Http\Controllers\Controller;
  use Illuminate\Foundation\Auth\AuthenticatesUsers;
  
  class LoginController extends Controller
  {
      /*
      |--------------------------------------------------------------------------
      | Login Controller
      |--------------------------------------------------------------------------
      |
      | This controller handles authenticating users for the application and
      | redirecting them to your home screen. The controller uses a trait
      | to conveniently provide its functionality to your applications.
      |
      */
  
      use AuthenticatesUsers;
  
      /**
       * Where to redirect users after login.
       *
       * @var string
       */
      protected $redirectTo = '/dashboard';
  
      /**
       * Create a new controller instance.
       *
       * @return void
       */
      public function __construct()
      {
          $this-&gt;middleware('guest')-&gt;except('logout');
      }
      public function showLoginForm()
      {
          return view('customlogin');
      }
  
  
  }
  </code></pre>
  
  <p>User Table Model :</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Support\Facades\Schema;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateUsersTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('users', function (Blueprint $table) {
              $table-&gt;engine = 'InnoDB';
              $table-&gt;increments('id');
              $table-&gt;string('name');
              $table-&gt;string('email',150)-&gt;unique();
              $table-&gt;string('password');
              $table-&gt;integer('roleid')-&gt;unsigned();
              $table-&gt;rememberToken();
              /*Common Fields*/
              $table-&gt;integer('status');
              $table-&gt;integer('createdby');
              $table-&gt;integer('modifiedby');
              $table-&gt;string('publicguid');
              $table-&gt;string('privateguid');
              $table-&gt;timestamps();
  
             /*From other table */
  
  
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
  
      public function down()
      {
          Schema::dropIfExists('users');
      }
  }
  </code></pre>