小编Dus*_*tin的帖子

类型错误:传递给 Controller::show() 的参数 2 必须是模态的实例,给定的字符串

向分类页面添加上下投票功能。使用 Laravel 和 Vue。

我得到的错误是:

(1/1) FatalThrowableError 类型错误:传递给 Hustla\Http\Controllers\ListingVoteController::show() 的参数 2 必须是 Hustla\Listing 的一个实例,给出的字符串

我已经包含了 vue 文件、投票控制器、列表模型和路由。我希望有人可以帮助我。

上市模式

 public function votesAllowed()
 {
     return (bool) $this->allow_votes;
 }

 public function commentsAllowed()
 {
     return (bool) $this->allow_comments;
 }

 public function votes()
 {
  return $this->morphMany(Vote::class, 'voteable');
 }

 public function upVotes()
 {
     return $this->votes()->where('type', 'up');
 }

 public function downVotes()
 {
     return $this->votes()->where('type', 'down');
 }

 public function voteFromUser(User $user)
 {
     return $this->votes()->where('user_id', $user->id);
 }
Run Code Online (Sandbox Code Playgroud)

投票控制器

  public function show(Request $request, Listing $listing)
  {

    $response = [
        'up' => …
Run Code Online (Sandbox Code Playgroud)

php laravel vue.js

2
推荐指数
1
解决办法
3501
查看次数

标签 统计

laravel ×1

php ×1

vue.js ×1