TiagoSilvaPereira / vemto-filament-plugin

A Vemto plugin for generating Filament admin panels
21 stars 9 forks source link

Table (index) and forms (create/edit) error if using different relationship name #3

Closed jay2success closed 2 years ago

jay2success commented 2 years ago

Hi,

Thanks for amazing plugin.

I found issue when testing this plugin.

Example there are User and BlogPost models.

User has many BlogPost. BlogPost: user_id belongsTo User, with relationship name: user()

The problem is if i use different foreign key and relationship name, example: BlogPost: author_id belongsTo User, with relationship name: author()

When building the BlogPostResource for filament:

  1. on form fn() BelongToSelect()->relationship('user', 'name') should be: BelongToSelect()->relationship('author', 'name')

  2. on table fn() Tables\Columns\TextColumn::make('user.name')->limit(50), should be: Tables\Columns\TextColumn::make('author.name')->limit(50),

and

MultiSelectFilter::make('author_id')->relationship( 'user', 'name' ), should be MultiSelectFilter::make('author_id')->relationship( 'author', 'name' ),

Thanks.

TiagoSilvaPereira commented 2 years ago

Hi @jay2success thank you for reporting... tagging @nicollassilva

nicollassilva commented 2 years ago

Hi @jay2success , this issue has been fixed for the next version of the plugin coming out soon. Thank you.

TiagoSilvaPereira commented 2 years ago

Added to latest version

jay2success commented 2 years ago

Awesome, thanks for the support.