/**
  * 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]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(RoleRequest $request)
 {
     try {
         $regra = Role::create($request->all());
         $regra->permissions()->attach($request->get('permissoes', array()));
         $regra->save();
         flash()->success("Regra cadastrada com Sucesso!");
         return redirect()->route('regras.index');
     } catch (ModelNotFoundException $e) {
         flash()->error("Desculpe, ocorreu um erro ao cadastrada a regra!");
         return redirect()->route('regras.create');
     }
 }