public function index()
 {
     $courses = Centre::with('courses')->get();
     $papers = Paper::with('courses')->get();
     $levels = Level::with('levels')->get();
     $courseNum = Course::all();
     return view('acca.base')->withCentres($courses)->withPapers($papers)->withLevels($levels)->with('courseNum', $courseNum);
 }
Exemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $papers = Paper::with('reviewer', 'user', 'requests');
     $department = null;
     if (!$this->systemAdmin) {
         $department = auth()->user()->department_id;
     } else {
         if (request('department_id') && $this->systemAdmin) {
             $department = request('department_id');
         }
     }
     if ($department) {
         $papers->where('department_id', (int) $department);
     }
     if (request('status_id')) {
         $papers->where('status_id', (int) request('status_id'));
     }
     if (request('category_id')) {
         $papers->where('category_id', (int) request('category_id'));
     }
     if (request('from')) {
         $papers->whereDate('created_at', '>=', Carbon::createFromFormat('m/d/Y', request('from'))->format('Y-m-d'));
     }
     if (request('to')) {
         $papers->whereDate('created_at', '<=', Carbon::createFromFormat('m/d/Y', request('to'))->format('Y-m-d'));
     }
     if (request('title')) {
         $papers->where('title', 'like', '%' . request('title') . '%');
     }
     if (request('user_id')) {
         $papers->where('user_id', (int) request('user_id'));
         $user = User::find((int) request('user_id'));
         session()->set('info-raw', $user->name . ' ' . trans('static.uploaded-papers'));
     }
     if (request('reviewer_id')) {
         $papers->where('reviewer_id', (int) request('reviewer_id'));
         $reviewer = User::find((int) request('reviewer_id'));
         session()->set('info-raw', $reviewer->name . ' ' . trans('static.reviewed-papers'));
     }
     if (session('department_filter_id')) {
         $papers = $papers->where('department_id', session('department_filter_id'));
     }
     $papers = $papers->archived()->get();
     return view('admin.paper.index', ['papers' => $papers, 'title' => trans('static.menu-papers'), 'url' => action('Admin\\PaperController@create'), 'search' => ['title', 'department', 'category', 'status', 'date'], 'search_url' => action('Admin\\PaperController@index'), 'counter' => count($papers), 'export' => 1]);
 }