samedi 16 janvier 2016

Belongs to many not finding class in laravel 5.1

I have a L 5.1 app with roles and permissions. By using Tutorial Link , I am trying to create permissions for specific routes. Now I have model within app directory Role.php as :

namespace App\Role;

use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
} 

And my User.php model is:

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, SoftDeletes;
    ------
    ------
    public function roles()
    {
        return $this->belongsToMany('App\Role');
    }
}

But when I log in , it throws the error

FatalErrorException in Model.php line 986: Class 'App\Role' not found

What I am doing wrong ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire