Benjacho / belongs-to-many-field-nova

Belongs To Many field Laravel nova to represent many to many relationship in field.
MIT License
157 stars 81 forks source link

Bug with direct Class access #82

Open flatcapco opened 3 years ago

flatcapco commented 3 years ago

Hey I have a Room model and resource. It has a column value of "name"

The way I'm calling the code actually doesnt use the "name" column but the "title()" set on the room resource:

    public function title(): string
    {
        return $this->model()->property->name . ': ' . $this->model()->name;
    }

This code below was working fine for me until I updated:

BelongsToManyField::make('Rooms', 'rooms', Room::class),

However on the latest update I now have to do the following:

BelongsToManyField::make('Rooms', 'rooms', Room::class)->optionsLabel('name'),

Weirdly its still using the title() method to display the label.. (which is good for me) but without the options label it just spits an error out (its trying to assign the string (label) rather than id on save).

I'm using 1.9 .. previously was 1.8 I believe