© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
andy_holmes

Filament v2 - $this->record doesn't exist when using a simple resource

Title pretty much says it all, I'm exploring Filament v2 and trying to make a simple modal that creates a user, manipulates the password to be a random string, and then fires an email once saved. When I used this code on a normal resource, everything worked fine. However, when using a simple resource, I keep getting a "Property [$record] not found on component: [app.filament.resources.user-resource.pages.manage-users]" error.

The code in my
ManageUser.php
ManageUser.php
file is as follows:
   <?php
    
    namespace App\Filament\Resources\UserResource\Pages;
    
    use Filament\Pages\Actions;
    ...
    
    class ManageUsers extends ManageRecords
    {
        protected static string $resource = UserResource::class;
    
        protected function getActions(): array
        {
            return [
                CreateAction::make()
                    ->mutateFormDataUsing(function (array $data): array {
                        $data['password'] = Hash::make(Str::random(30));
    
                        return $data;
                    })
                    ->after(function(array $data) {
                        dd($this->record);
                        $token = Str::random(35);
    
                        DB::table('password_reset_tokens')->insert([
                            'email' => $this->record->email,
                            'token' => bcrypt($token),
                            'created_at' => now(), 
                        ]);
    
                        event(new Registered($this->record));
                        $this->record->notify(new ResetPassword($token));
                    })
            ];
        }
    }
   <?php
    
    namespace App\Filament\Resources\UserResource\Pages;
    
    use Filament\Pages\Actions;
    ...
    
    class ManageUsers extends ManageRecords
    {
        protected static string $resource = UserResource::class;
    
        protected function getActions(): array
        {
            return [
                CreateAction::make()
                    ->mutateFormDataUsing(function (array $data): array {
                        $data['password'] = Hash::make(Str::random(30));
    
                        return $data;
                    })
                    ->after(function(array $data) {
                        dd($this->record);
                        $token = Str::random(35);
    
                        DB::table('password_reset_tokens')->insert([
                            'email' => $this->record->email,
                            'token' => bcrypt($token),
                            'created_at' => now(), 
                        ]);
    
                        event(new Registered($this->record));
                        $this->record->notify(new ResetPassword($token));
                    })
            ];
        }
    }


I'm a bit lost as to what the issue is, have I missed a step, or misundertood something?
Solution
I think you can inject the
$record
$record
parameter into
after
after
:
    ->after(function ($record) {
        // ...
    })
    ->after(function ($record) {
        // ...
    })
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Repeater simple doesn't exist
FilamentFFilament / ❓┊help
3y ago
Using a Livewire form inside a Filament Resource (simple)
FilamentFFilament / ❓┊help
3y ago
Simple Repeater for Filament v2
FilamentFFilament / ❓┊help
3y ago
filament resource doesn't show any data
FilamentFFilament / ❓┊help
3y ago