php - Laravel 5 belongsToMany() on custom table

Solution:
Have you set the primary key on your "userrole" model?
Laravel automatically assume that you're primary key is namedid
.
See this: http://laravel.com/docs/5.1/eloquent
Take a look at the primary key section:
Eloquent will also assume that each table has a primary key column named
id
. You may define a$primaryKey
property to override this convention.
Try to override it at youruserrole
model like so:
protected $primaryKey = 'roleId';
Try to read all the doccumentattion carefully.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: warning: a non-numeric value encountered in
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.