我得到 BadMethodCallException Call to undefined method App\Models\User::identifiableAttribute()

I get BadMethodCallException Call to undefined method App\Models\User::identifiableAttribute()

单击应用程序前端的 'New Post' 按钮后出现此错误:
帖子视图

我的日志文件中的行:
[2020-09-27 14:41:03] local.ERROR: 调用未定义的方法 App\Models\User::identifiableAttribute() {"exception":"[object] (BadMethodCallException(code : 0): 在 C:\xampp\htdocs\backpack-demo\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php:50)

调用未定义方法 App\Models\User::identifiableAttribute()

我正在使用 Laravel 7 + Backpack CRDU 生成器

帖子管理员:

<?php

namespace App\Http\Controllers;

use App\Events\NewPost;
use App\Http\Requests\PostStoreRequest;
use App\Jobs\SyncMedia;
use App\Mail\ReviewPost;
use App\Models\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;

class PostController extends Controller
{
    /**
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(Request $request)
    {
        $posts = Post::all();

        return view('post.index', compact('posts'));
    }

    /**
     * @param \App\Http\Requests\PostStoreRequest $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function store(PostStoreRequest $request)
    {
        $post = Post::create($request->validated());

        Mail::to($post->author->email)->send(new ReviewPost($post));

        SyncMedia::dispatch($post);

        event(new NewPost($post));

        $request->session()->flash('post.title', $post->title);

        return redirect()->route('post.index');
    }
}

帖子模型:

 class Post extends Model
    {
        use CrudTrait;
        /**
         * The attributes that are mass assignable.
         *
         * @var array
         */
        protected $fillable = [
            'title',
            'content',
            'published_at',
            'author_id',
        ];
    
        /**
         * The attributes that should be cast to native types.
         *
         * @var array
         */
        protected $casts = [
            'id' => 'integer',
            'author_id' => 'integer',
        ];
    
        /**
         * The attributes that should be mutated to dates.
         *
         * @var array
         */
        protected $dates = [
            'published_at',
        ];
    
        public static function create(array $validated)
        {
        }
    
    
        public function author()
        {
            return $this->belongsTo(User::class);
        }
    }

用户模型:

class User extends Authenticatable
{
    use Notifiable;

    /**
     * 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',
    ];
}

您忘记在您的用户模型中使用 'CrudTrait':

use Backpack\CRUD\app\Models\Traits\CrudTrait;

class User extends Authenticatable
{
  use Notifiable,CrudTrait
    .......
 }