我的用户照片有问题试图获取非对象的属性“头像”

时间:2019-04-07 15:41:13

标签: php laravel laravel-5 laravel-5.7

  

试图获取非对象的属性“头像”(查看:   C:\ xampp \ htdocs \ Admin \ resources \ views \ inc \ header.blade.php)(查看:   C:\ xampp \ htdocs \ Admin \ resources \ views \ inc \ header.blade.php)(查看:   C:\ xampp \ htdocs \ Admin \ resources \ views \ inc \ header.blade.php)

我不在此页面上使用控制器,所以我真的不知道该怎么做

 <img src="/uploads/avatars/{{ Auth::user()->avatar }}" class="img-circle" alt="User Image">

迁移

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('avatar')->default('default.jpg');
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
}

模型

    use Spatie\Permission\Traits\HasRoles;


class User extends Authenticatable
{
    use Notifiable;
    use HasRoles;


    protected $fillable = [
        'name', 'email', 'password',
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];

    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    public function setPasswordAttribute($password)
{   
    $this->attributes['password'] = bcrypt($password);
}
}

{{ Auth::user()->'...' }}出现时错误就会出现

        Spatie\Permission\PermissionServiceProvider::class,

我希望在中间件中出现问题或控制器会导致问题,在我使用(用户权限)功能实现我的网站之前没有问题

0 个答案:

没有答案