generated from theradcoza/Laravel-Docker-Dev-Template
34 lines
1005 B
PHP
34 lines
1005 B
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\ParticipantResource\Pages;
|
|
|
|
use App\Filament\Resources\ParticipantResource;
|
|
use Filament\Resources\Pages\CreateRecord;
|
|
|
|
class CreateParticipant extends CreateRecord
|
|
{
|
|
protected static string $resource = ParticipantResource::class;
|
|
|
|
protected function mutateFormDataBeforeCreate(array $data): array
|
|
{
|
|
$minutes = $data['time_minutes'] ?? null;
|
|
$seconds = $data['time_seconds'] ?? null;
|
|
$milliseconds = $data['time_milliseconds'] ?? null;
|
|
|
|
if ($minutes !== null || $seconds !== null || $milliseconds !== null) {
|
|
$data['best_time_ms'] = ((int)$minutes * 60000) + ((int)$seconds * 1000) + (int)$milliseconds;
|
|
} else {
|
|
$data['best_time_ms'] = null;
|
|
}
|
|
|
|
unset($data['time_minutes'], $data['time_seconds'], $data['time_milliseconds']);
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function getRedirectUrl(): string
|
|
{
|
|
return $this->getResource()::getUrl('index');
|
|
}
|
|
}
|