© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
KeyMe

Relationship record not automatically created in resource View page action

I have an Order model with relationship of hasOne Training model.
After order creation, there is an action modal in the ViewOrder page that prompt user to enter remarks.
Upon action submission, I was hoping a related Training record would be created if not existed yet, else its remarks field should be updated but alas only updating existing record works. I've simplified the code below for review purpose.

Action::make('requestReviseOrder')
    ->form([
         TextArea::make('remarks')
    ])
    ->action(function (array $data): void     {
        $this->record->training()-  >update($data);
        $this->fillForm();
    }
Action::make('requestReviseOrder')
    ->form([
         TextArea::make('remarks')
    ])
    ->action(function (array $data): void     {
        $this->record->training()-  >update($data);
        $this->fillForm();
    }

Order class
public function training(): HasOne
    {
        return $this->hasOne(Training::class);
    }
public function training(): HasOne
    {
        return $this->hasOne(Training::class);
    }

Training class
public function order(): BelongsTo
    {
        return $this->belongsTo(Order::class);
    }
public function order(): BelongsTo
    {
        return $this->belongsTo(Order::class);
    }
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Go to record on "view" in Relationship managed resource.
FilamentFFilament / ❓┊help
3y ago
Conditional action on view resource page
FilamentFFilament / ❓┊help
3y ago
Edit action in relationship manager not working for view page
FilamentFFilament / ❓┊help
3y ago
Testing view page in nested resource
FilamentFFilament / ❓┊help
7mo ago