コード例 #1
0
 public function __construct()
 {
     $this->user_id = Auth::getUser()->id;
     $role_obj = new RoleUser();
     $this->role_id = $role_obj->getRoleById($this->user_id);
     $role_policy_ojb = new RolePolicy();
     $this->policy_id = $role_policy_ojb->getPolicyByRoleId($this->role_id->role_id);
 }
コード例 #2
0
ファイル: UsernhcController.php プロジェクト: nattaphat/cuse2
 /**
  * [userApprovalSave save method of user information after approval]
  * @param  [integer] $id [user id]
  * @return [none]     [redirect to user list]
  */
 public function userApprovalSave($id)
 {
     $data = Input::all();
     //var_dump($data);exit;
     $rules = array('user_approve' => 'required');
     $messages = array('user_approve.required' => 'กรุณาระบุสถานะการใช้งาน');
     $validator = Validator::make($data, $rules, $messages);
     //var_dump($validator->messages());exit;
     if ($validator->passes()) {
         $usernhc = Usernhc::find($id);
         $usernhc->status = $data['user_approve'];
         //approve user
         $usernhc->grp_id = $data['user_grp'];
         //promote user
         $usernhc->save();
         //set role to user
         // //DB::table('role_user')
         // 		->where('user_id','=',$id)
         // 		->update(array('role_id' => $data['role_approve']));
         $roleuser = new RoleUser();
         $_roleuser = $roleuser->getRoleById($id);
         if (isset($_roleuser)) {
             //if it exist
             RoleUser::where('user_id', '=', $id)->update(array('role_id' => $data['role_approve']));
         } else {
             $roleuser->role_id = $data['role_approve'];
             //role id
             $roleuser->user_id = $id;
             //user id
             $roleuser->save();
         }
         // $rolepolicy = new RolePolicy;
         // $rolepolicy->role_id = $data['role_approve'];//role id
         // $rolepolicy->policy_id = $id;//user id
         // $roleuser->save();
         if ($data['user_approve'] == 'yes') {
             //Send email when status is allow to user.
             self::emailToUser($usernhc->email, $usernhc->fname . ' ' . $usernhc->lname, $data['user_approve'], $data['user_grp'], $data['role_approve']);
         }
         return Redirect::route('userlist');
     } else {
         return Redirect::to('/userlist/approval/' . $id)->withErrors($validator);
     }
 }