How to stop the importing process

How to stop the importing process if a subscription plan limit is reached? I try it like so, but it is not working. I mean it does not import records but always shows a Notification with import started. This should not be the case.
ImportAction::make()
->importer(ClientImporter::class)
->beforeFormValidated(function () {
$subscription = app(Subscription::class, ['user' => auth()->user()]);
if ($subscription->hasReachedLimitForResource('client', 'import')) {
Notification::make()
->title('You have reached the limit for importing clients.')
->danger()
->send();
return;
}
})
ImportAction::make()
->importer(ClientImporter::class)
->beforeFormValidated(function () {
$subscription = app(Subscription::class, ['user' => auth()->user()]);
if ($subscription->hasReachedLimitForResource('client', 'import')) {
Notification::make()
->title('You have reached the limit for importing clients.')
->danger()
->send();
return;
}
})
1 Reply
NullPointer
NullPointerOP2mo ago
I have the solution you can do just
$action->cancel();
$action->cancel();

Did you find this page helpful?