End year procedures implementation #111

Merged
okorpheus merged 6 commits from EndYearProcedures into master 2025-05-30 03:13:24 +00:00
2 changed files with 36 additions and 0 deletions
Showing only changes of commit 095881761c - Show all commits

View File

@ -0,0 +1,34 @@
<?php
namespace App\Actions\YearEndProcedures;
use App\Models\HistoricalSeat;
use App\Models\Seat;
use Carbon\Carbon;
class RecordHistoricalSeats
{
public function __construct()
{
}
public function __invoke(): void
{
$this->saveSeats();
}
public function saveSeats(): void
{
$seats = Seat::all();
foreach ($seats as $seat) {
$student_id = $seat->student->id;
$year = Carbon::now()->year;
$seat_description = $seat->ensemble->name.' - '.$seat->audition->name.' - '.$seat->seat;
HistoricalSeat::create([
'student_id' => $student_id,
'year' => $year,
'seat_description' => $seat_description,
]);
}
}
}

View File

@ -10,6 +10,8 @@ class HistoricalSeat extends Model
{
use HasFactory;
protected $guarded = [];
public function student(): BelongsTo
{
return $this->belongsTo(Student::class);