title: Laravel 8: Argument 2 passed must be an instance of
body: <p>I'm working with Laravel 8 to develop an Online Forum. And I made this form for updating an answer of a user:</p>
  <pre><code>&lt;form action=&quot;{{ route('update.answer', [$anss-&gt;id, $que-&gt;id]) }}&quot; method=&quot;POST&quot;&gt;
      @csrf
      &lt;textarea name=&quot;answer&quot; id=&quot;answer&quot; class=&quot;form-control&quot; rows=&quot;7&quot;&gt;{{ $ans-&gt;answer }}&lt;/textarea&gt;
      @error('answer')
          &lt;div class=&quot;text-red-500 mt-2 text-sm&quot;&gt;
              {{ $message }}
          &lt;/div&gt;
      @enderror
      &lt;button type=&quot;submit&quot; class=&quot;text-blue-500 BJadidBold&quot;&gt;ثبت تفییرات&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>And here is the route for this:</p>
  <pre><code>Route::post('questions/{ans}/{que}' , [QuestionController::class, 'updateAnswer'])-&gt;name('update.answer');
  </code></pre>
  <p>And this is also the Method of <code>QuestionController</code>:</p>
  <pre><code>public function updateAnswer(Answer $anss, Question $que)
      {
          $validate_data = Validator::make(request()-&gt;all(),[
             'answer' =&gt; 'required'
          ])-&gt;validated();
  
          $answer = Answer::findOrFail($anss);
          $answer-&gt;update($validate_data);
          return view('questions.question',[
              'show' =&gt; $que,
          ]);
      }
  </code></pre>
  <p>But now the problem is, whenever I submit the form in order to update answer, I get this as error:</p>
  <p><strong>Argument 2 passed to App\Http\Controllers\QuestionController::updateAnswer() must be an instance of App\Models\Question, string given, called in F:\xampp\htdocs\gooyanet\root\vendor\laravel\framework\src\Illuminate\Routing\Controller.php on line 54</strong></p>
  <p>I don't why I get this error, because as you can see I have passed <code>$que-&gt;id</code> at Action to <code>Question $que</code> as the 2nd parameter of <code>udpateAnswer()</code> method.</p>
  <p>So what is your idea about this? How can I solve this issue?</p>
  <p>I would really appreciate if you share your idea or suggestion with me.</p>
  <p>Thanks...</p>