致命错误:找不到特征“ App \ Commenter”

时间:2019-04-04 18:25:53

标签: php laravel-5

我是laravel和php的新手

我正在使用Actuallymab/comment为我的应用创建评论系统。

我对此进行了测试:

testcommenteract.php

<?php

require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

use App\User;
Use App\Post;

$user = App\User::first();
$product = App\Post::first();

// $user->comment(Commentable $model, $comment = '', $rate = 0);
$user->comment($product, 'Lorem ipsum ..', 3);

// approve it -- if the user model `canCommentWithoutApprove()` or you don't use `mustBeApproved()`, it is not necessary
$product->comments[0]->approve();

// get avg rating -- it calculates approved average rate.
$product->averageRate();

// get total comments count -- it calculates approved comments count.
$product->totalCommentsCount();

它给了我这个错误:

Fatal error: Trait 'App\Commenter' not found in C:\xampp2\htdocs\galaxall\app\User.php on line 15

请帮助

1 个答案:

答案 0 :(得分:0)

默认情况下,应将模型添加到app文件夹中。此外,使用Laravel,不需要在框架内完成自动加载文件的操作。