Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dutchprogrammer's avatar

BelongsToMany: nova adds hyphen between 2 word model “LongFeature”

In short: Nova is looking for relationship App\Course::long-features() instead of App\Course::longFeatures()

Long version: In Laravel I have 3 models:

Course
Benefit
LongFeature

In the nova resource "nova/Course.php" I've created these relationships:

BelongsToMany::make('Benefits'),
BelongsToMany::make('LongFeatures'),

The relationship with "Benefits" works well.

But the relationship with "LongFeatures" has an issue. I can see the relationships on the nova Course view page: Course view page

but when I want to attach a new "LongFeature" I get an error message:

Call to undefined method App\Course::long-features()

The error appears on this page /nova/resources/courses/1/attach/long-features?viaRelationship=longfeatures&polymorphic=0

So it is putting a hyphen between the 2 words. It's looking for App\Course::long-features(), but it should look App\Course::longFeatures()

I've already tried this without luck: BelongsToMany::make('LongFeatures', 'longFeatures', 'App\Nova\LongFeature'),

Any suggestions? Thanks!

Im on versions: "laravel/nova": "3.22.0", "laravel/framework": "8.35.1"

0 likes
0 replies

Please or to participate in this conversation.