title: Passing URL parameter to post request form in Laravel
body: <p>When users click to apply for a certain job vacancy they are redirected to a form with the URL format:</p>
  <pre><code>.../jobs/{job}/create`
  </code></pre>
  <p>where {job} is the id.</p>
  <p>I want to pass this id to the store function so that users can fill out the form, submit and all the data will be stored in the database, including the id that is passed. However, it does not seem to work and I get the following array_merge() error:</p>
  <blockquote>
  <p>array_merge(): Expected parameter 2 to be an array, string given</p>
  </blockquote>
  <p>This are the routes I use, one to redirect to the form page and the other to store the form submission:</p>
  <pre><code>Route::get('/jobs/{job}/create', 'App\Http\Controllers\ApplicationsController@create');
  Route::post('/applications', 'App\Http\Controllers\ApplicationsController@store');
  </code></pre>
  <p>These are the functions in my controller</p>
  <pre><code>    public function create($job)
      {
          return view('applications/create', $job);
      }
  
      public function store(Request $request, $job)
      {
          $application = new \App\Models\Application;
  
          // Set object properties from the user input
          $application-&gt;job_id = $request-&gt;input($job);
          $application-&gt;user_id = $request-&gt;input('user_id');
          $application-&gt;message = $request-&gt;input('message');
          // Set default label (new)
          $application-&gt;label_id = &quot;1&quot;;
  
          $application-&gt;save();
  
          return redirect('applications');
      }
  
  </code></pre>
  <p>And this is my form</p>
  <pre><code>    &lt;div class=&quot;wrapper bg-light&quot;&gt;
          &lt;h1&gt;Apply for job&lt;/h1&gt;
          &lt;form action=&quot;/applications&quot; method=&quot;post&quot;&gt;
              {{ csrf_field() }}
  
              &lt;label for=&quot;message&quot;&gt;Write a motivation letter&lt;/label&gt;
              &lt;br&gt;
              &lt;textarea name=&quot;message&quot; id=&quot;message&quot; cols=&quot;30&quot; rows=&quot;10&quot;&gt;&lt;/textarea&gt;
              &lt;br&gt;&lt;br&gt;
  
              &lt;label for=&quot;user_id&quot;&gt;User id&lt;/label&gt;
              &lt;input type=&quot;number&quot; name=&quot;user_id&quot; id=&quot;user_id&quot;&gt;
              &lt;br&gt;&lt;br&gt;
  
              &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>