public static function store($files, $material) { // Making counting of uploaded images $file_count = count($files); // start count how many uploaded $uploadcount = 0; if (!empty($files)) { foreach ($files as $file_path) { if (!empty($file_path)) { $type = File::type($file_path); $mime = File::mimeType($file_path); $extension = File::extension($file_path); $filename = $material->slug . '_' . str_replace(' ', '_', File::name($file_path)) . '.' . $extension; File::move($file_path, storage_path() . '/app/' . $filename); //add file path and thumb path to material_files database $material_file = MaterialFile::firstOrCreate(['original_filename' => File::name($file_path), 'filename' => $filename, 'mime' => $mime]); //add to material file table $material->files()->save($material_file); $uploadcount++; //create thumb MaterialFile::makeThumb($extension, $filename); } } if ($uploadcount == $file_count) { Session::flash('success', 'Upload(s) successfully'); } else { return Redirect::to('material.edit')->withInput(); } } }
public function deleteEntry($fid, $pid) { $rules = ['id' => 'required|integer']; $inputs = ['id' => $pid]; $deleted = $this->doDelete($pid, $inputs, $rules); if ($deleted['status'] == 1) { return Redirect::to('/crm/feature/' . $fid)->withMessage(Generate::message('SUCCESS', $deleted['message'])); } return Redirect::to('/crm/feature/' . $fid)->withMessage(Generate::message('FAILED', $deleted['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.')); }
public function makeCreatePermissionForm($fid) { $feature = Feature::find($fid); if (!isset($feature)) { return Redirect::to('/crm/feature')->withMessage(Generate::message('Invalid', 'Invalid Feature or Feature has been deleted')); } $all_positions = Permission::getAllCurrentPosition(); $icons = SysConfig::getSystemConfig('Icons'); $icon_bgs = SysConfig::getSystemConfig('IconBG'); $all_pages = Permission::getAllCurrentPages(); $all_prompt_types = Permission::getAllCurrentPromptTypes(); return View::make('backend.feature.create_permission')->with('feature', $feature)->with('icons', $icons)->with('icon_bgs', $icon_bgs)->with('all_prompt_types', $all_prompt_types)->with('all_pages', $all_pages)->with('all_positions', $all_positions)->with('module', $this->module); }
public static function refreshUserSession() { $user_id = Session::get('user')['id']; $user = User::find($user_id); if (Auth::login($user)) { Session::flush(); // if() Session::put('user', $user->toArray()); Session::put('navtop', User::getNavTop($user_id)['data']); Session::put('sidebar', User::getSidebar($user_id)['data']); Session::put('permissions', User::getUserPermission($user_id)['data']); Session::put('features', User::getUserFeatures($user_id)['data']); return Redirect::to(Session::get('navtop')['home_url']); } }