/** * Displya a list of assignments. * * @return Response */ public function all_reports() { $user = Auth::user(); $reports = []; if ($user->hasRole('admin')) { $reports = Report::all(); } else { if ($user->hasRole('tutor')) { foreach ($user->tutor_assignments as $assignment) { foreach ($assignment->reports as $report) { array_push($reports, $report); } } } else { if ($user->hasRole('professor')) { foreach ($user->professor_assignments as $assignment) { foreach ($assignment->reports as $report) { array_push($reports, $report); } } } } } $data = array('reports' => $reports); return view('reports', $data); }
public function index(Manager $fractal, ReportTransformer $reportTransformer) { // show all $records = Report::all(); $collection = new Collection($records, $reportTransformer); $data = $fractal->createData($collection)->toArray(); return $this->respond($data); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::table('results')->delete(); $faker = Faker::create(); foreach (Report::all() as $report) { $coefficients = array(); $organizationIndicators = $report->owner->organization->indicators; foreach ($organizationIndicators as $organizationIndicator) { $coefficients[$organizationIndicator->id] = $organizationIndicator->pivot->coefficient; } foreach ($report->users as $user) { foreach ($report->indicators as $indicator) { $value = $indicator->type == 'value' ? $faker->randomNumber(3) : $faker->randomFloat(3, 0, 1); $points = $value * $coefficients[$indicator->id]; Result::create(['report_id' => $report->id, 'user_id' => $user->id, 'indicator_id' => $indicator->id, 'value' => $value, 'points' => $points]); } $report->evaluated_at = Carbon::now(); $report->save(); } } Model::reguard(); }
public function reports() { return view('admin.main')->with('reports', Report::all()); }
public function vueGetRequest() { return Report::all(); }
public function getIndex() { return Response::json(Report::all()); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { if (Gate::denies('account.update')) { return view(config('app.template') . '.error.403'); } $account = Account::with('reports')->find($id); if (!$account) { return view(config('app.template') . '.error.404'); } $data = ['reports' => Report::all(), 'account' => $account, 'types' => Account::$types]; return view(config('app.template') . '.account.update', $data); }
public function allReports() { return Report::all(); }