32 lines
801 B
PHP
32 lines
801 B
PHP
<?php
|
|
|
|
namespace App\Actions\Tabulation;
|
|
|
|
use App\Models\Audition;
|
|
use App\Models\Seat;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class PublishSeats
|
|
{
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function __invoke(Audition $audition, array $seats): void
|
|
{
|
|
// Delete from the seats table where audition_id = $audition->id
|
|
Seat::where('audition_id', $audition->id)->delete();
|
|
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');
|
|
Cache::forget('resultsSeatList');
|
|
}
|
|
}
|