orlyapps / nova-belongsto-depend

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

Does not work when using title() method #11

Closed noahlocke closed 6 years ago

noahlocke commented 6 years ago

The multi-select field is expecting a titleKey attribute for the custom label, but if the Nova Resource title is set with the title() method, then all you get is the Id in custom label.

orlyapps commented 6 years ago

Thanks for this issus. Im looking into this.

albalooshi commented 6 years ago

@orlyapps Any ETA on this issue?

srottem commented 6 years ago

I'm also affected - I thought I had a fix for this but was wrong. :(

orlyapps commented 6 years ago

Hello,

this is in my opinion not a bug. You can archive a custom title this way:


class ExampleModel extends Model
{
    protected $appends = ['title'];

    public function getTitleAttribute()
    {
        return $this->attributes['name'] . ' custom';
    }
}

class ExampleModel extends Resource
{

    public static $model = 'App\ExampleModel';

    public static $title = 'title';

}

I have updated the demo project

https://github.com/orlyapps/laravel-nova-demo
albalooshi commented 6 years ago

@orlyapps thanks!