filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.07k stars 2.83k forks source link

HasManyThrough Relation Manager problem when trying to add record #7513

Closed guiofranca closed 1 year ago

guiofranca commented 1 year ago

Package

filament/filament

Package Version

3.0.8

Laravel Version

10.17.1

Livewire Version

No response

PHP Version

8.2.8

Problem description

When trying to save a model using a HasManyThrough relation in the Relation Manager the application throws an exception.

https://flareapp.io/share/W7z8XNVm

Expected behavior

It was expected to save the model.

Steps to reproduce

There are instructions on the reproduction repository.

The error also happens on the demo page under Customers->Payments. Pick a Customer with any Orders placed and try to add a Payment. https://demo.filamentphp.com/shop/customers

Reproduction repository

https://github.com/guiofranca/relation-manager-error

Relevant log output

No response

guiofranca commented 1 year ago

I could get it to work by changing the line https://github.com/filamentphp/filament/blob/3.x/packages/tables/src/Actions/CreateAction.php#L66C39-L66C39 to:

if (! $relationship || $relationship instanceof HasManyThrough) {

    $record->save();

    return $record;
}

I don't know how it would affect other features.

danharrin commented 1 year ago

Please submit a PR if you can