matab-panel/app/Filament/Resources/PrescriptionResource/Pages/CreatePrescription.php

54 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Resources\PrescriptionResource\Pages;
use App\Filament\Resources\PrescriptionResource;
use Filament\Resources\Pages\CreateRecord;
use Filament\Support\Enums\Width;
class CreatePrescription extends CreateRecord
{
protected static string $resource = PrescriptionResource::class;
protected Width|string|null $maxContentWidth = Width::SevenExtraLarge;
public string $printType = '';
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['doctor'] = auth()->user()?->name;
$data['issue_datetime'] = now();
return $data;
}
protected function getFormActions(): array
{
return [];
}
protected function getRedirectUrl(): string
{
$record = $this->getRecord();
if ($this->printType === 'prescription') {
return route('prescription.print', $record);
}
if ($this->printType === 'lab') {
return route('prescription.print', ['prescription' => $record, 'type' => 'lab']);
}
if ($this->printType === 'both') {
return route('prescription.print', ['prescription' => $record, 'type' => 'both']);
}
if ($this->printType === 'admission') {
return route('prescription.print.admission', $record);
}
return static::getResource()::getUrl('index');
}
}