Call to a member function getForeignKeyName() on null
I dont know why it's not working, I have the main table
access_permits
structure
and this is the other table access_permit_vehicles
structure:
5 Replies
these are the models
Vehicle:
AccessPermit:
and this is the migration for
access_permit_vehicles
:
this is for access_permits
Looks like your relationships are off based on laravel conventions.
May you kindly explain what this means?
Eloquent determines the foreign key name by examining the name of the relationship method and suffixing the method name with _id.
If you stick to the conventions of model classnames, relationship names and the proper column names it should work out without too much hassle. Read up on the documentation here > https://laravel.com/docs/11.x/eloquent-relationships#defining-relationships
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.