52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Tabulation;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Entry;
|
|
use App\Models\EntryFlag;
|
|
use App\Services\DoublerService;
|
|
use App\Services\EntryService;
|
|
|
|
class DoublerDecisionController extends Controller
|
|
{
|
|
protected $doublerService;
|
|
protected $entryService;
|
|
|
|
public function __construct(DoublerService $doublerService, EntryService $entryService)
|
|
{
|
|
$this->doublerService = $doublerService;
|
|
$this->entryService = $entryService;
|
|
}
|
|
|
|
public function accept(Entry $entry)
|
|
{
|
|
$doublerInfo = $this->doublerService->simpleDoubleInfo($entry);
|
|
foreach ($doublerInfo as $doublerEntry) {
|
|
/** @var Entry $doublerEntry */
|
|
if ($doublerEntry->id !== $entry->id) {
|
|
$doublerEntry->addFlag('declined');
|
|
}
|
|
}
|
|
|
|
|
|
$returnMessage = $entry->student->full_name().' accepted seating in '.$entry->audition->name;
|
|
|
|
return redirect()->back()->with('success', $returnMessage);
|
|
|
|
}
|
|
|
|
public function decline(Entry $entry)
|
|
{
|
|
if ($entry->hasFlag('declined')) {
|
|
return redirect()->back()->with('caution', 'Entry is already declined');
|
|
}
|
|
|
|
$entry->addFlag('declined');
|
|
|
|
$returnMessage = $entry->student->full_name().' declined seating in '.$entry->audition->name;
|
|
|
|
return redirect()->back()->with('success', $returnMessage);
|
|
}
|
|
}
|