30 lines
771 B
PHP
30 lines
771 B
PHP
<?php
|
|
|
|
namespace App\Actions\Tabulation;
|
|
|
|
use App\Models\Entry;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
class GetBonusScoreRelatedEntries
|
|
{
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
public function __invoke(Entry $entry): Collection
|
|
{
|
|
return $this->getRelatedEntries($entry);
|
|
}
|
|
|
|
public function getRelatedEntries(Entry $entry): Collection
|
|
{
|
|
$bonusScore = $entry->audition->bonusScore->first();
|
|
$relatedAuditions = $bonusScore->auditions;
|
|
|
|
// Get all entries that have a student_id equal to that of entry and an audition_id in the related auditions
|
|
return Entry::where('student_id', $entry->student_id)
|
|
->whereIn('audition_id', $relatedAuditions->pluck('id'))
|
|
->get();
|
|
}
|
|
}
|