39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Judging;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\BonusScore;
|
|
use App\Models\BonusScoreDefinition;
|
|
use App\Models\Entry;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use function redirect;
|
|
|
|
class BonusScoreEntryController extends Controller
|
|
{
|
|
/**
|
|
* Displays a form for a judge to enter a bonus score for an entry.
|
|
*/
|
|
public function __invoke(Entry $entry)
|
|
{
|
|
// We can't submit another bonus score for this entry if we have already submitted one.
|
|
if (BonusScore::where('entry_id', $entry->id)->where('user_id', Auth::user()->id)->exists()) {
|
|
return redirect()->route('judging.bonusScore.EntryList', $entry->audition)->with('error',
|
|
'You have already judged that entry');
|
|
}
|
|
|
|
/** @var BonusScoreDefinition $bonusScore */
|
|
$bonusScore = $entry->audition->bonusScore()->first();
|
|
if (! $bonusScore->judges->contains(auth()->id())) {
|
|
return redirect()->route('judging.index')->with('error', 'You are not assigned to judge that entry');
|
|
}
|
|
|
|
$maxScore = $bonusScore->max_score;
|
|
$bonusName = $bonusScore->name;
|
|
|
|
return view('judging.bonus_entry_score_sheet', compact('entry', 'maxScore', 'bonusName'));
|
|
|
|
}
|
|
}
|