How to override filament default form data store method

I'm looking to customize the default form data storage method in Filament. Specifically, I aim to direct the submitted form data to the CreateVehicle action class within the domain layer. Which function should I override to achieve this?
9 Replies
shashika
shashikaOP10mo ago
This doesn't work.. please help
Prosp30
Prosp3010mo ago
Share some code
shashika
shashikaOP10mo ago
sure. <?php namespace App\Filament\Company\Resources\VehicleResource\Pages; use App\Enums\Status; use App\Filament\Company\Resources\VehicleResource; use App\Models\Company; use App\Models\VehicleCategory; use App\Models\VehicleType; use Filament\Resources\Pages\CreateRecord; use Illuminate\Support\Facades\Auth; use Localift\Vehicle\Actions\CreateVehicle as LocaliftCreateVehicle; class CreateVehicle extends CreateRecord { protected static string $resource = VehicleResource::class; public function __construct( private LocaliftCreateVehicle $createVehicle ) { } protected function beforeCreate(): void { //dd($this->data['vehicle_category_id']); $this->createVehicle->execute( $this->data['name'], Status::ACTIVE->toStatus(), VehicleType::query()->find($this->data['vehicle_type_id'])->toVehicleType(), VehicleCategory::query()->find($this->data['vehicle_category_id'])->toVehicleCategory(), Company::query()->find(Auth::id())->toCompany(), $this->data['name'], ); } }
shashika
shashikaOP10mo ago
error
No description
shashika
shashikaOP10mo ago
I want data pass to CreateVehicle Action class.
Melchior
Melchior10mo ago
Dont override the constructor, or call the parent constructor
CerealKiller
CerealKiller10mo ago
parent::__construct();
parent::__construct();
Is missing
shashika
shashikaOP10mo ago
use below methodpublic function handleRecordCreation(array $data): Model {
} Thank you everyone 🫡
Want results from more Discord servers?
Add your server