Issue
I am creating a custom user package for use in Laravel 4.
I am running in to a little difficulty setting up my relationship in the User model. Here is the relationship:
public function roles()
{
return $this->belongsToMany('Role');
}
Now, for some reason this is resulting in a Class 'Role' not found error. Everything in src/models gets auto-loaded via composer in the composer.json file for that package:
"classmap": [
"src/migrations",
"src/controllers",
"src/models",
"src/repositories"
],
Any suggestions?
(I have tried the obvious composer dump-autoload, composer update etc.)
Solution
return $this->belongsToMany('Role');
is just a string
so you needed the full path like this:
return $this->belongsToMany('path\to\Models\Role');
Answered By - George Garchagudashvili
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.