auditionadmin/app/helpers.php

58 lines
1.3 KiB
PHP

<?php
use App\Actions\Tabulation\EnterScore;
use App\Exceptions\ScoreEntryException;
use App\Models\AuditLogEntry;
use App\Models\Entry;
use App\Models\User;
use App\Settings;
use Illuminate\Support\Facades\App;
function tw_max_width_class_array(): array
{
$return = [
'xs' => 'max-w-xs',
'sm' => 'max-w-sm',
'md' => 'max-w-md',
'lg' => 'max-w-lg',
'xl' => 'max-w-xl',
'2xl' => 'max-w-2xl',
'3xl' => 'max-w-3xl',
'4xl' => 'max-w-4xl',
'5xl' => 'max-w-5xl',
'6xl' => 'max-w-6xl',
'7xl' => 'max-w-7xl',
'full' => 'max-w-full',
'fit' => 'max-w-fit',
'min' => 'max-w-min',
'max' => 'max-w-max',
];
return $return;
}
function auditionSetting($key)
{
return Settings::get($key);
}
function auditionLog(string $message, array $affected)
{
AuditLogEntry::create([
'user' => auth()->user()->email ?? 'no user',
'ip_address' => request()->ip(),
'message' => $message,
'affected' => $affected,
]);
}
/**
* @throws ScoreEntryException
*/
function enterScore(User $user, Entry $entry, array $scores): \App\Models\ScoreSheet
{
$scoreEntry = App::make(EnterScore::class);
return $scoreEntry($user, $entry, $scores);
}