Run function while creating record not on editing.

Hi everyone, I'm working on a Filament project, specifically in the MovieManagementResource, and I want to run the generateDateSchedules method only when creating a new movie. I am trying to use request()->routeIs('filament.admin.resources.movie-managements.create') in the afterStateUpdated callback of the DatePicker, but it doesn't seem to be working. Here’s part of my code: Forms\Components\DatePicker::make('release_date') ->required() ->reactive() ->afterStateUpdated(function (Set $set, Get $get, $state) { if (request()->routeIs('filament.admin.resources.movie-managements.create')) { $releaseDate = Carbon::parse($state); $endDate = Carbon::parse($get('end_date')); if ($endDate) { self::generateDateSchedules($set, $releaseDate, $endDate); } } });
Solution:
Try operation: ```php ->afterStateUpdated(function (Set $set, Get $get, $state, string $operation) { if ($operation == 'create') { dd($operation);...
Jump to solution
3 Replies
Solution
Vp
Vp3mo ago
Try operation:
->afterStateUpdated(function (Set $set, Get $get, $state, string $operation) {
if ($operation == 'create') {
dd($operation);
}
})
->afterStateUpdated(function (Set $set, Get $get, $state, string $operation) {
if ($operation == 'create') {
dd($operation);
}
})
Aditya Khadka | Nepal
Than you very much sir.
Want results from more Discord servers?
Add your server