Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filament\Tables\Table::getInverseRelationshipFor(): Argument #1 ($record) must be of type Illuminate\Database\Eloquent\Model #12115

Closed
classicalguss opened this issue Mar 30, 2024 · 3 comments · Fixed by #12470
Labels
bug Something isn't working low priority unconfirmed
Milestone

Comments

@classicalguss
Copy link

classicalguss commented Mar 30, 2024

Package

filament/filament

Package Version

v3.2.0

Laravel Version

v10.0.0

Livewire Version

No response

PHP Version

PHP 8.2.17

Problem description

I am trying to use Associate::make()->multiple on a HasMany - BelongsTo relation.

Searching and picking works fine, but as soon as I hit save I get the error. If I removed multiple() it will work fine.

Please keep in mind that I had to put

Expected behavior

Expected to save correctly.

Steps to reproduce

My models are as follows

class Company extends Model
{
    use HasFactory;

     public function users(): HasMany
     {
	return $this->hasMany(User::class);
     }

}

And in User Model

public function company(): BelongsTo
{
	return $this->belongsTo(Company::class);
}

I ran this to produce the relation manager
php artisan make:filament-relation-manager CompanyResource users name --associate
And my code in the relation manager table() function is as follows

            ->headerActions([
                Tables\Actions\AssociateAction::make()->multiple()
            ])

Reproduction repository

https://github.com/classicalguss/curly-disco

Relevant log output

No response

Copy link

Hey @classicalguss! We're sorry to hear that you've hit this issue. 💛

However, it looks like you forgot to fill in the reproduction repository URL. Can you edit your original post and then we'll look at your issue?

We need a public GitHub repository which contains a Laravel app with the minimal amount of Filament code to reproduce the problem. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. That would allow us to download it and review your bug much easier, so it can be fixed quicker. Please make sure to include a database seeder with everything we need to set the app up quickly.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
Copy link

Thank you for providing reproduction steps! Reopening the issue now.

@github-actions github-actions bot reopened this Mar 30, 2024
@zepfietje zepfietje added this to the v3 milestone Apr 3, 2024
@saade
Copy link
Member

saade commented Apr 18, 2024

I think the problem here its that when using multiple() $data['recordId'] will be an array, then the if will not run since $record will be a Collection.

$record = $relationship->getQuery()->find($data['recordId']);

dmitry-udod added a commit to dmitry-udod/filament that referenced this issue Apr 24, 2024
@dmitry-udod dmitry-udod mentioned this issue Apr 24, 2024
3 tasks
@danharrin danharrin linked a pull request Apr 24, 2024 that will close this issue
3 tasks
danharrin added a commit that referenced this issue Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working low priority unconfirmed
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants