orlyapps / nova-belongsto-depend

Larave Nova BelongsTo Field with Dependcy
MIT License
182 stars 65 forks source link

titleKey #3

Closed ardyn closed 6 years ago

ardyn commented 6 years ago

The following line $this->titleKey = Nova::resourceForKey(str_plural($this->attribute))::$title; is failing when the model has a non-standard BelongsTo relationship method name.

We need to be able to set $this->titleKey manually.

I passed in a fourth argument to make method and then changed code to $this->titleKey = $titleKey ?? Nova::resourceForKey(str_plural($this->attribute))::$title;

orlyapps commented 6 years ago

Hello,

thanks for your bug report. This commit https://github.com/orlyapps/nova-belongsto-depend/commit/b3e5619cb7b1c513fe930cad33c7d80e3f1bc482 should fix your problem.

I have also created a demo project: https://github.com/orlyapps/laravel-nova-demo

Can you try it again?

ardyn commented 6 years ago

That works.

Ideally it should use the resources title() method, but that requires the model to be instantiated and not called statically.

On Fri, Sep 7, 2018 at 8:32 AM Orlyapps notifications@github.com wrote:

Hello,

thanks for your bug report. This commit b3e5619 https://github.com/orlyapps/nova-belongsto-depend/commit/b3e5619cb7b1c513fe930cad33c7d80e3f1bc482 should fix your problem.

I have also created a demo project: https://github.com/orlyapps/laravel-nova-demo

Can you try it again?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/orlyapps/nova-belongsto-depend/issues/3#issuecomment-419424906, or mute the thread https://github.com/notifications/unsubscribe-auth/AHgh_gtJORE8r9_mtZbAlqaen8AEnwxNks5uYmdJgaJpZM4Wd_DI .

glennwilton commented 6 years ago

Just tried the latest version, TitleKey fix also worked for me. Ok to close