/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::truncate();
     Role::create(['role_string' => 'MASTER', 'role_slug' => 'role_master', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
     DB::table('permission_role')->insert(['permission_id' => Permission::where('permission_slug', '=', 'permission_master')->first()->id, 'role_id' => Role::where('role_slug', '=', 'role_master')->first()->id]);
     DB::table('permission_role')->insert(['permission_id' => Permission::where('permission_slug', '=', 'permission_user_simple')->first()->id, 'role_id' => Role::where('role_slug', '=', 'role_master')->first()->id]);
 }
 /**
  * @param $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function show($id)
 {
     try {
         $usuario = User::find($id);
         $users_role = $usuario->roles->toArray();
         foreach ($users_role as $ur) {
             $user_role[] = $ur['pivot']['role_id'];
         }
         $dados = ['page_title' => 'Usuários', 'dados' => $usuario, 'action' => route('usuarios.update', $id), 'roles' => Role::all(), 'user_role' => $user_role];
         return view('auth.edit', $dados);
     } catch (ModelNotFoundException $e) {
         flash()->error('Desculpe, erro ao mostrar usuário');
         return redirect()->route('usuarios.index');
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     User::create(['name' => 'Administrador Master', 'email' => '*****@*****.**', 'password' => Hash::make('s@wil123#'), 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
     DB::table('role_user')->insert(['user_id' => User::where('email', '=', '*****@*****.**')->first()->id, 'role_id' => Role::where('role_slug', '=', 'role_master')->first()->id]);
 }
 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function recovery($id)
 {
     try {
         Role::onlyTrashed()->findOrFail($id)->restore();
         flash()->success('Regra recuperado com sucesso!');
         return redirect()->route('regras.index');
     } catch (ModelNotFoundException $e) {
         flash()->error('Desculpe, Regra não foi encontrado.');
         return redirect()->route('regras.index');
     }
 }