how to make $shouldRollbackDatabaseTransaction to true in Halt class

In BasePage class: protected function halt(): void { throw new Halt(); } ----------------------------------------------------------- In CreateRecord class -> create method -> Halt Catch block: $exception->shouldRollbackDatabaseTransaction() ? $this->rollBackDatabaseTransaction() : $this->commitDatabaseTransaction(); return; ------------------------------------------------------------ In Customer Resource -> CreateCustomer Page Class : protected ?bool $hasDatabaseTransactions = true; handleRecordCreation method: $record = static::getModel()::create($data); if (! $record) { app('helpers')::toast( title: __('customer.error_message.create'), color: 'danger' ); $this->halt(); } -------------------------------------------------------------- here how to rollback the transaction if halt hits
1 Reply
Parthiban N
Parthiban N4w ago
i do this throw (new Halt)->rollBackDatabaseTransaction(); instead of $this->halt(); to rollback transaction but the filament BasePage class have halt method but it doesn't have the option to set rollback true But in Mountable Action Class have this: public function halt(bool $shouldRollBackDatabaseTransaction = false): void { throw (new Halt())->rollBackDatabaseTransaction($shouldRollBackDatabaseTransaction); }