public function edit() { if (Request::ajax() && Request::isMethod('post')) { if (Input::has('userinfo')) { $userinfo = json_decode(Input::get('userinfo'), TRUE); if (User::find(Auth::id())->userinfo->fill($userinfo)->save()) { return json_encode(array('status' => true, 'msg' => 'Done updating user info!')); } else { return json_encode(array('msg' => 'Unable to update user info, Please Try Again')); } } elseif (Input::has('password')) { $password = json_decode(Input::get('password'), TRUE); $user = User::find(Auth::id()); if (isset($password['old_password']) && isset($password['new_password']) && Hash::check($password['old_password'], $user->password)) { $user->password = Hash::make($password['new_password']); if ($user->save()) { return json_encode(array('status' => true, 'msg' => 'Done updating password!')); } else { return json_encode(array('msg' => 'Unable to update user info, Please Try Again')); } } } } return json_encode(array('msg' => 'Unable to update user info, Please Try Again')); }
public static function getPageAction($module_id, $page_id) { $where = array('group_id' => User::find(Auth::id())->group->group_id, 'module_id' => $module_id, 'page_id' => $page_id); $permission = Permission::where($where)->get()->toArray(); if (count($permission) == 0) { App::abort(403, 'Unauthorized action.'); } return $permission[0]['action_value']; }
public function index() { $this->checkModule(); $action_value = Permission::getPageAction($this->page_module, $this->page_id); $group_id = User::find(Auth::id())->group_id; if ($group_id != 1) { $this->diplayError(404); } return view('content.setting.company.company', array('action_value' => $action_value)); }
public function data() { $this->checkPageAction($this->page_id, Action::$View); if (Request::ajax()) { if (Input::has('draw') && Input::get('draw')) { $model_name = 'App\\Models\\ACL\\Group'; $data = array('tbl_company.company_name', 'tbl_group.group_name', 'tbl_group.group_name', 'tbl_group.group_name', 'tbl_group.group_id'); $joins = array('tbl_company,tbl_company.company_id,=,tbl_group.company_id,inner'); $user = User::find(Auth::id()); $company_id = $user->group->company_id; $where_raw = 'tbl_group.group_id <> 1 '; $where_array = array(); if ($company_id != 1) { $where_raw .= 'AND tbl_group.group_name <> "Admin"'; $where_array['company_id'] = $company_id; } $start = Input::get('start'); $length = Input::get('length'); $search = Input::get('search'); $order = Input::get('order'); $response = $this->filterData($model_name, $data, $start, $length, $order, $search, $joins, $where_array, $where_raw); foreach ($response['data'] as &$data) { $data['modules'] = $this->getModules($data->group_id); $data['pages'] = $this->getPages($data->group_id); } return json_encode($response); } } }
public static function checkUserModule($module_id) { $module_ids = array_unique(User::find(Auth::id())->group->permission->lists('module_id')); return in_array($module_id, $module_ids); }
private function checkUserValidation($user_id) { $user = User::find($user_id); if (!is_null($user->brand) && count($user->brand->toArray()) != 0) { return false; } return true; }