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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?