【问题标题】:Trait 'Laravelista\Comments\Comments\Traits\Comments' not found未找到特征“Laravelista\Comments\Comments\Traits\Comments”
【发布时间】:2019-04-04 08:05:09
【问题描述】:

我刚刚下载了一个名为 laravelista/comments 的 laravel 搜索类

文档很少,所以我不是很了解所有内容。

基本上,当我在输入我的详细信息并在'localhost:8000/login' 中按submit 后尝试这样做时,它会将我定向到 laravel PrettyPageHandler 并向我显示此错误:

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Trait 'Laravelista\Comments\Comments\Traits\Comments' not found

我已经下载了 laravelista/cmets 并运行所有命令,例如:

php artisan vendor:publish --provider="Laravelista\Comments\Providers\CommentsServiceProvider" --tag=migrations

php artisan migrate


php artisan vendor:publish --provider="Laravelista\Comments\Providers\CommentsServiceProvider" --tag=config

php artisan vendor:publish --provider="Laravelista\Comments\Providers\CommentsServiceProvider" --tag=public --force

但我仍然收到该错误

在我的 User.php 中:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravelista\Comments\Comments\Traits\Comments;


class User extends Authenticatable
{
    use Notifiable;
    use Comments;


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

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

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

请帮忙。

【问题讨论】:

标签: php class laravel-5 traits


【解决方案1】:

我只需要将 User.php 更改为

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;


use Laravelista\Comments\Commenter;


class User extends Authenticatable
{
    use Notifiable,Commenter;



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

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

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

我用错了use

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-06
    • 2022-08-20
    • 2010-12-24
    • 1970-01-01
    • 2022-12-02
    • 1970-01-01
    • 2021-01-06
    • 2014-06-24
    相关资源
    最近更新 更多