70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Tabulation;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Audition;
|
|
use App\Models\Seat;
|
|
use App\Services\AuditionService;
|
|
use App\Services\DoublerService;
|
|
use App\Services\SeatingService;
|
|
use App\Services\TabulationService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use function compact;
|
|
|
|
class TabulationController extends Controller
|
|
{
|
|
protected $tabulationService;
|
|
|
|
protected $doublerService;
|
|
|
|
protected $seatingService;
|
|
|
|
protected $auditionService;
|
|
|
|
public function __construct(TabulationService $tabulationService,
|
|
DoublerService $doublerService,
|
|
SeatingService $seatingService,
|
|
AuditionService $auditionService)
|
|
{
|
|
$this->tabulationService = $tabulationService;
|
|
$this->doublerService = $doublerService;
|
|
$this->seatingService = $seatingService;
|
|
$this->auditionService = $auditionService;
|
|
}
|
|
|
|
|
|
public function publishSeats(Request $request, Audition $audition)
|
|
{
|
|
// TODO move this to SeatingService
|
|
$sessionKey = 'audition'.$audition->id.'seatingProposal';
|
|
$seats = $request->session()->get($sessionKey);
|
|
foreach ($seats as $seat) {
|
|
Seat::create([
|
|
'ensemble_id' => $seat['ensemble_id'],
|
|
'audition_id' => $seat['audition_id'],
|
|
'seat' => $seat['seat'],
|
|
'entry_id' => $seat['entry_id'],
|
|
]);
|
|
}
|
|
$audition->addFlag('seats_published');
|
|
$request->session()->forget($sessionKey);
|
|
Cache::forget('resultsSeatList');
|
|
|
|
// TODO move the previous Cache functions here and in unplublish to the services, need to add an event for publishing an audition as well
|
|
return redirect()->route('tabulation.audition.seat', ['audition' => $audition->id]);
|
|
}
|
|
|
|
public function unpublishSeats(Request $request, Audition $audition)
|
|
{
|
|
// TODO move this to SeatingService
|
|
$audition->removeFlag('seats_published');
|
|
Cache::forget('resultsSeatList');
|
|
Seat::where('audition_id', $audition->id)->delete();
|
|
|
|
return redirect()->route('tabulation.audition.seat', ['audition' => $audition->id]);
|
|
}
|
|
}
|