feat: initial commit

This commit is contained in:
JP
2024-08-05 08:04:35 +08:00
parent 0f3c3db73b
commit 140e821e0c
194 changed files with 14509 additions and 254 deletions

View File

@@ -0,0 +1,93 @@
<?php
namespace App\Filament\Resources\TransmittalResource\Pages;
use App\Exports\TransmittalsExport;
use App\Filament\Resources\TransmittalResource;
use App\Jobs\ExportCompleteJob;
use Filament\Actions;
use Filament\Actions\Action;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
use Filament\Support\Exceptions\Halt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Throwable;
use Filament\Notifications\Actions\Action as NotificationAction;
class CreateTransmittal extends CreateRecord
{
protected static string $resource = TransmittalResource::class;
protected function getFormActions(): array
{
return [
$this->getCreateFormAction(),
$this->getCreateAnotherFormAction(),
Action::make('Create and Export')->action('saveAndExport')->color('success'),
$this->getCancelFormAction()
];
}
/**
* @throws Throwable
*/
public function saveAndExport(): void
{
$this->authorizeAccess();
try {
DB::beginTransaction();
$this->callHook('beforeValidate');
$data = $this->form->getState();
$this->callHook('afterValidate');
$data = $this->mutateFormDataBeforeCreate($data);
$this->callHook('beforeCreate');
$this->record = $this->handleRecordCreation($data);
$this->form->model($this->getRecord())->saveRelationships();
$this->callHook('afterCreate');
DB::commit();
} catch (Halt $exception) {
$exception->shouldRollbackDatabaseTransaction() ?
DB::rollBack() :
DB::commit();
return;
} catch (Throwable $exception) {
DB::rollBack();
throw $exception;
}
$this->rememberData();
TransmittalResource::exportTransmittal([$this->record->id]);
Notification::make()
->success()
->title('Transmittal Was Created Successfully!, Check your notification for file download link')
->send();
}
public function getCreatedNotificationMessage(): ?string
{
return 'Transmittal Was Created Successfully!'; // TODO: Change the autogenerated stub
}
protected function getRedirectUrl(): string
{
return $this->previousUrl ?? $this->getResource()::getUrl('index');
}
}