85 lines
3.0 KiB
PHP
85 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Actions\Entries\GetEntrySeatingResult;
|
|
use App\Actions\Tabulation\CalculateEntryScore;
|
|
use App\Actions\Tabulation\RankAuditionEntries;
|
|
use App\Models\AuditionFlag;
|
|
use App\Models\School;
|
|
use App\Services\Invoice\InvoiceDataService;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use function redirect;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
protected InvoiceDataService $invoiceService;
|
|
|
|
public function __construct(InvoiceDataService $invoiceService)
|
|
{
|
|
$this->invoiceService = $invoiceService;
|
|
}
|
|
|
|
public function profile()
|
|
{
|
|
return view('dashboard.profile');
|
|
}
|
|
|
|
public function dashboard(
|
|
CalculateEntryScore $scoreCalc,
|
|
GetEntrySeatingResult $resultGenerator,
|
|
RankAuditionEntries $ranker
|
|
) {
|
|
|
|
// Info for director results report
|
|
// $entries = Auth::user()->entries;
|
|
// $entries = $entries->filter(function ($entry) {
|
|
// return $entry->audition->hasFlag('seats_published');
|
|
// });
|
|
// $entries = $entries->sortBy(function ($entry) {
|
|
// return $entry->student->full_name(true);
|
|
// });
|
|
// $scores = [];
|
|
// $results = [];
|
|
// $ranks = [];
|
|
// foreach ($entries as $entry) {
|
|
// $results[$entry->id] = $resultGenerator->getResult($entry);
|
|
// if (! $entry->hasFlag('no_show') && ! $entry->hasFlag('failed_prelim')) {
|
|
// $scores[$entry->id] = $scoreCalc->calculate('seating', $entry);
|
|
// $auditionResults = $ranker->rank('seating', $entry->audition);
|
|
// $ranks[$entry->id] = $auditionResults->firstWhere('id', $entry->id)->raw_rank;
|
|
// }
|
|
// }
|
|
// $showRecapLink = AuditionFlag::where('flag_name', 'seats_published')->count() > 0;
|
|
|
|
//return view('dashboard.dashboard', compact('entries', 'scores', 'results', 'ranks', 'showRecapLink'));
|
|
return view('dashboard.dashboard');
|
|
}
|
|
|
|
public function my_school()
|
|
{
|
|
if (Auth::user()->school) {
|
|
return redirect('/schools/'.Auth::user()->school->id);
|
|
}
|
|
$possibilities = Auth::user()->possibleSchools();
|
|
if (count($possibilities) < 1) {
|
|
return view('schools.create');
|
|
}
|
|
$schools = School::orderBy('name')->get();
|
|
|
|
return view('dashboard.select_school', ['possibilities' => $possibilities, 'schools' => $schools]);
|
|
}
|
|
|
|
public function my_invoice()
|
|
{
|
|
if (! Auth::user()->school_id) {
|
|
return redirect()->route('dashboard')->with('error', 'You do not have a school to get an invoice for');
|
|
}
|
|
$invoiceData = $this->invoiceService->allData(Auth::user()->school_id);
|
|
$school = Auth::user()->school;
|
|
|
|
return view('dashboard.invoice', compact('school', 'invoiceData'));
|
|
}
|
|
}
|