Exemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id = "")
 {
     //
     $validator = Validator::make($request->all(), ['name' => 'required', 'description' => 'required', 'level' => 'required']);
     if ($validator->fails()) {
         return \Redirect::back()->withErrors($validator)->withInput();
     }
     $input = $request->all();
     array_forget($input, "_token");
     $role = Role::find($input['id']);
     foreach ($input as $key => $val) {
         $role->{$key} = $val;
     }
     if ($role->update()) {
         $role->permissions()->sync([2, 3, 4, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28]);
         \Session::flash("success_message", "Role Successfully Updated");
         return \Redirect::back();
     }
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id = "")
 {
     //
     $input = $request->all();
     $validator = Validator::make($input, ['firstname' => 'required', 'lastname' => 'required', 'email' => 'required', 'username' => 'required']);
     if ($validator->fails()) {
         return \Redirect::back()->withErrors($validator)->withInput();
     }
     $user = !empty($id) ? \Toddish\Verify\Models\User::find($input['id']) : $id;
     $role = \Toddish\Verify\Models\Role::find($input['role_id']);
     $user->firstname = $input['firstname'];
     $user->lastname = $input['lastname'];
     $user->phone = $input['phone'];
     $user->username = $input['username'];
     $user->email = $input['email'];
     $user->verified = $input['verified'];
     $user->disabled = $input['disabled'];
     // $user->created_by_id = \Auth::user()->id;
     //$user->created_by    = \Auth::user()->firstname ." ".\Auth::user()->lastname;
     try {
         if ($user->update()) {
             $user->roles()->sync([$role->id]);
             /* \DB::table('dblogs')->insert(
                    ['user_id' => \Auth::user()->id, 'post_id' => $user->id,"description"=>"A new user has been committed to data store","action"=>"New user created awaits approval action",
                        "post_type"=>"user","operator"=>\Auth::user()->firstname ." ". \Auth::user()->lastname,"created_at"=>date('Y-m-d H:i:s')]
                );*/
             \Session::flash("success_message", "New User Record Updated Successfully");
             return \Redirect::back();
         }
     } catch (\Illuminate\Database\QueryException $e) {
         \Session::flash("error_message", $e->getMessage());
         return \Redirect::back();
     } catch (\PDOException $e) {
         \Session::flash("error_message", $e->getMessage());
         return \Redirect::back();
     } catch (\Exception $e) {
         \Session::flash("error_message", $e->getMessage());
         return \Redirect::back();
     }
     //}
 }
Exemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $mod = Role::create(['name' => 'Moderator', 'level' => 7]);
     $perms = \Toddish\Verify\Models\Permission::all(['id']);
     $mod->permissions()->sync($perms);
 }