【问题标题】:Class 'App\Model' not found after add Bican\Roles添加 Bican\Roles 后找不到类 'App\Model'
【发布时间】:2017-09-18 20:54:51
【问题描述】:

我正在使用 Bican Roles 库。我将 User.php 更改为:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Bican\Roles\Traits\HasRoleAndPermission;
use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasRoleAndPermissionContract
{
    use Authenticatable, CanResetPassword, HasRoleAndPermission,Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'surnames', 'email', 'password','phone',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

尝试注册新用户时抛出以下错误:

找不到类“应用\模型”

我已尝试添加它

使用用户;

等但仍然无法正常工作,有什么想法吗?谢谢

【问题讨论】:

    标签: php laravel-5


    【解决方案1】:

    你需要添加

    use Illuminate\Database\Eloquent\Model;
    

    到你的班级声明的顶部,而不是use User;

    你得到的错误是

    找不到类“应用\模型”

    不是

    找不到类“用户”

    【讨论】:

      【解决方案2】:

      试试

       use Illuminate\Database\Eloquent\Model;
      

      【讨论】:

        猜你喜欢
        • 2020-02-02
        • 2017-12-06
        • 2018-02-25
        • 2016-05-22
        • 1970-01-01
        • 2020-03-07
        • 1970-01-01
        • 2020-08-11
        • 1970-01-01
        相关资源
        最近更新 更多