/** * Handle an incoming request. * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!app()->make('ConferenceBaseController')->getDepartment() && !isAdminPanel()) { return redirect('/' . LaravelLocalization::setLocale()); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (isAdminPanel()) { #required for department admin and system admin check $id = $request->segment(4); } else { $department = app()->make('ConferenceBaseController')->getDepartment(); $id = $department->id; } if (!auth()->guest() && $id != auth()->user()->department_id) { #if user is logged but not from that department logout him if (isAdminPanel()) { return redirect()->action('Admin\\DepartmentController@index'); } auth()->logout(); } return $next($request); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $rules = ['category_id' => 'required|exists:category,id', 'title' => 'required|min:3|max:255', 'description' => 'min:3|max:1000', 'paper' => 'required|max:32000|mimes:pdf,doc,docx', 'authors' => 'required|min:3|max:255']; if (isAdminPanel()) { $paper = new PaperStatus(); if (systemAccess(100)) { $rules['department_id'] = 'required'; } $rules['user_id'] = 'required|exists:users,id'; $rules['payment_description'] = 'min:3|max:1000'; $rules['payment_source'] = 'image|max:5000'; $rules['status_id'] = 'required|between:1,' . count($paper->getStatuses()); } if ($this->request->get('id')) { #update request1 if (!$this->request->get('paper')) { $rules['paper'] = ''; } } return $rules; }
public function delete() { if ($this->paper->status_id == 1 || isAdminPanel()) { try { $this->paper->delete(); } catch (Exception $e) { return false; } $this->deleteFile(); $this->deleteInvoice(); return true; } return false; }