Accept/Decline buttons are working
This commit is contained in:
parent
a1f5191a19
commit
e1aa852142
|
|
@ -21,22 +21,15 @@ class DoublerDecisionController extends Controller
|
|||
|
||||
public function accept(Entry $entry)
|
||||
{
|
||||
$doublerInfo = $this->doublerService->getDoublerInfo($entry->student_id);
|
||||
foreach ($doublerInfo as $info) {
|
||||
$this->entryService->clearEntryCacheForAudition($info['auditionID']);
|
||||
if ($info['entryID'] != $entry->id) {
|
||||
try {
|
||||
EntryFlag::create([
|
||||
'entry_id' => $info['entryID'],
|
||||
'flag_name' => 'declined',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', 'Entry ID'.$info['entryID'].' has already been declined.');
|
||||
}
|
||||
|
||||
$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);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
||||
use Staudenmeir\BelongsToThrough;
|
||||
use App\Models\ScoreSheet;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class Entry extends Model
|
||||
{
|
||||
|
|
@ -39,7 +38,6 @@ class Entry extends Model
|
|||
return $this->belongsTo(Audition::class);
|
||||
}
|
||||
|
||||
|
||||
public function school(): HasOneThrough
|
||||
{
|
||||
return $this->hasOneThrough(
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ class DoublerService
|
|||
'seating' => $entries->filter(fn ($entry) => $entry->for_seating === 1),
|
||||
'advancement' => $entries->filter(fn ($entry) => $entry->for_advance === 1),
|
||||
};
|
||||
$entries->load('student.school');
|
||||
$entries->load('audition');
|
||||
#$entries->load('student.school');
|
||||
#$entries->load('audition');
|
||||
$grouped = $entries->groupBy('student_id');
|
||||
// Filter out student groups with only one entry in the event
|
||||
$grouped = $grouped->filter(fn ($s) => $s->count() > 1);
|
||||
|
|
@ -61,6 +61,14 @@ class DoublerService
|
|||
return $doubler_array;
|
||||
}
|
||||
|
||||
public function simpleDoubleInfo(Entry $primaryEntry)
|
||||
{
|
||||
if (! isset($this->findDoublersForEvent($primaryEntry->audition->event)[$primaryEntry->student_id])) {
|
||||
return false;
|
||||
}
|
||||
return $this->findDoublersForEvent($primaryEntry->audition->event)[$primaryEntry->student_id]['entries'];
|
||||
}
|
||||
|
||||
public function entryDoublerData(Entry $primaryEntry)
|
||||
{
|
||||
if (! isset($this->findDoublersForEvent($primaryEntry->audition->event)[$primaryEntry->student_id])) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue