public function updateRecord($id) { $inputs = Input::all(); $rules = ['name' => 'required', 'url' => 'required', 'icon' => 'required', 'module' => 'required']; $record = $this->doUpdate($id, $inputs, $rules); if ($record['status'] == 1) { return Redirect::to('/crm/feature/' . $id)->withMessage(Generate::message('SUCCESS', $record['message'])); } return Redirect::to('/crm/feature/' . $id)->withMessage(Generate::message('FAILED', $record['message'])); }
public function updateEntry($fid, $pid) { $inputs = Input::all(); $rules = ['feature_id' => 'required', 'name' => 'required', 'module' => 'required', 'position' => 'required', 'url' => 'required', 'page' => 'required', 'prompt_type' => 'required']; $updated = $this->doUpdate($pid, $inputs, $rules); //if create function return 1 - Success, !1 - Not Success if ($updated['status'] == 1) { //redirect to the url you wan along with the message return Redirect::to('/crm/feature/' . $fid)->withMessage(Generate::message('SUCCESS', $updated['message'])); } //redirect to the proper handling url along with the message return Redirect::to('/crm/feature/' . $fid)->withMessage(Generate::message('FAILED', $updated['message'])); }
public function assignRolePermission($rid) { $inputs = Input::all(); //get all the permission that this role has. $current_permissions_id = Role::getPermissionsAssignedToCurrentRole($rid); foreach ($inputs as $key => $value) { $is_permission_added_in_current_role = false; if ($key == '_token') { continue; } $permission_id = explode("_", $key)[1]; $is_permission_added_in_current_role = in_array($permission_id, $current_permissions_id); if (!$is_permission_added_in_current_role && $value == 'on') { echo 'ON'; print_r($current_permissions_id); echo $permission_id . '->'; echo $is_permission_added_in_current_role; echo '<br>'; //if the permission is not exist, create new permission role record. $new_permission = new PermissionRole(); $new_permission->role_id = $rid; $new_permission->permission_id = $permission_id; $new_permission->order = '1'; $new_permission->save(); //else since it is already exist, and it is on, no need to do anything. } else { if ($is_permission_added_in_current_role) { if ($value == 'off') { echo 'OFF'; print_r($current_permissions_id); echo $permission_id . '->'; echo $is_permission_added_in_current_role; echo '<br>'; //if permission record is exist (true), find and do a delete. $perm = PermissionRole::where('role_id', $rid)->where('permission_id', $permission_id)->first(); if (isset($perm)) { $perm->delete(); } //else it is not exist, do nothing. } else { if ($value == 'on') { //echo 'ON'; print_r ($current_permissions_id); echo $permission_id.'->'; echo $is_permission_added_in_current_role; echo '<br>'; //do nothing .... } } } } } //return ''; return Redirect::to('/crm/role/' . $rid)->withMessage(Generate::message('Success', 'New Permissions Applied, please relogin to see the changes.')); }