phplaraveleloquentlaravel-filament

How to get stored data in laravel filament afterCreate()


Laravel filament has afterCreate function that will trigger after data has been stored in the database

protected function afterCreate(): void
{
   // Runs after the form fields are saved to the database.
}

The question is, how do I get the 'stored' data? I need to save a log for it (in the different table) that require the id of the stored data


Solution

  • You can access the created record with $this->record.

    Also, this property is available in EditRecord.

    Here's an example from the filament itself.