title: How do Laravel route/controller parameters work?
body: <p>I understand that if I have a route of say api/users/{id} then this will get passed to the controller function as an $id param.</p>
  
  <p>However if I have a api route of:</p>
  
  <pre><code>Route::patch('roadmap/{roadmapcourse}', 'RoadmapCourseController@update');
  </code></pre>
  
  <p>and a controller method:</p>
  
  <pre><code>/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\RoadmapCourse $roadmapcourse
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, RoadmapCourse $roadmapcourse)
    {
      $data = $request-&gt;validate([
        'user_id' =&gt; 'required|integer',
        'course_id' =&gt; 'required|integer',
        'stage' =&gt; 'required|integer',
        'title' =&gt; 'required|string',
        'creator' =&gt; 'required|string',
        'url' =&gt; 'required|string',
        'hours' =&gt; 'required',
        'completed' =&gt; 'required|boolean'
      ]);
  
      $roadmapcourse-&gt;update($data);
  
      return response($roadmapcourse, 200);
    }
  </code></pre>
  
  <p>Then I send a request to http://<em>projectname</em>/api/roadmap/2 - then 2 gets passed through as the param to the update function doesn't it?</p>
  
  <p>But by the looks of the update function its expecting an instance of RoadmapCourse and not a single digit i.e. '2'?</p>
  
  <p>Does Laravel, behind the scenes, search for a database entry for a RoadmapCourse with the id of 2, and then bring that in to the function as $roadmapcourse?</p>
  
  <p>That's the only thing I can think of, and I can't find any documentation explaining what's going on.</p>
  
  <p>P.S I also can't find any documentation regarding the variable naming convention of Class $variable i.e. RoadmapCourse $roadmapcourse, I understand what it does, just can't find any docs.</p>
  
  <p>P.P.S I also can't find any documentation explaining the "docblocks" above a controller method e.g.</p>
  
  <pre><code>/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\RoadmapCourse $roadmapcourse
     * @return \Illuminate\Http\Response
     */
  </code></pre>
  
  <p>And what these '@param' declarations are actually for??</p>
  
  <p>Any help or links to docs would be appreciated (I've been looking at the Laravel docs but can't find any mention or any of these things - hence posting on here)</p>
  
  <p>Thanks! </p>