douxian1939 2019-04-04 18:25
浏览 171
已采纳

致命错误:找不到Trait'App \ Commenter'

I am new to laravel and php

I am using Actuallymab/comment to make a comment system for my app.

I tested it with this :

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();

It gives me this error:

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

please help

  • 写回答

1条回答 默认 最新

  • dongliulu1122 2019-04-07 17:01
    关注

    Models, by default, should be added to the app folder. Furthermore, with Laravel there shouldn't be a need to require the autoload file as this is done within the framework.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题