Support the ongoing development of Laravel.io →
posted 8 years ago
Eloquent
Last updated 2 years ago.
0

Listen!
As you can see from the stack trace the error occurs in the BelongsTo.php file. That means that you probably didn't define a belongsTo relationship correctly. package_type is of that type and causes the error. So, you chould search there.
The code tries to find a package_type_id property in your App\Featurepackage class. Why would it do that? It's because it assumes that the foreign key's name is package_type_id, which is expected behaviour.
Why is there no such property in the App\Featurepackage class? Because its dinamic properties are loaded from the database. So you have no package_type_id in the corresponding database table.
This means you're missing a foreign key column in your featurepackages table or the foreign key column doen't have the name package_type_id.

0

I don't think thats the problem, i've checked the database and relations are working correctly there, it's just a problem with getting the id of the related object in this method, getting it in other methods like in the controller and associating objects works fine.

0

Every time you access the package_type method (relationship), your App\Featurepackage class has to have a value for package_type_id. Since the column exists in the database, you are doing something wrong before saving it to the database.
Give more code from the stacktrace. Try to find a place where you create a new instance of App\Featurepackage and invoke the packageTypeId.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Kaeltis kaeltis Joined 28 May 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.