title: Laravel 5 Form Request data pre-manipulation
body: <p>I'm processing a form where a user can update their date of birth. The form gives the user 3 separate fields for <code>day</code>, <code>month</code> and <code>year</code>. On the server-side of course I want to treat these 3 separate fields as one value i.e. <code>yyyy-mm-dd</code>.</p>
  
  <p>So before validation and updating my database, I want to alter the form request to create a <code>date_of_birth</code> field by concatenating <code>year</code>, <code>month</code> and <code>day</code> with <code>-</code> characters to create the date format I need (And possibly unset the original 3 fields).</p>
  
  <p>Achieving this manually with my controller is not a problem. I can simply grab the input, join the fields together separated by <code>-</code> characters and unset them. I can then validate manually before passing off to a command to deal with the processing.</p>
  
  <p>However, I would prefer to use a <code>FormRequest</code> to deal with the validation and have that injected into my controller method. Therefore I need a way of actually modifying the form request before validation is executed.</p>
  
  <p>I did find the following question which is similar: <a href="https://stackoverflow.com/questions/28600823/laravel-5-request-altering-data">Laravel 5 Request - altering data</a></p>
  
  <p>It suggests overriding the <code>all</code> method on the form request to contain the logic for manipulating the data prior to validation.</p>
  
  <pre><code>&lt;?php namespace App\Http\Requests;
  
  class UpdateSettingsRequest extends Request {
  
      public function authorize()
      {
          return true;
      }
  
      public function rules()
      {
          return [];
      }
  
      public function all()
      {
          $data = parent::all();
          $data['date_of_birth'] = 'test';
          return $data;
      }
  </code></pre>
  
  <p>This is all well and good for the validation, but overriding the <code>all</code> method doesn't actually modify the data on the form request object. So when it comes to executing the command, the form request contains the original unmodified data. Unless I use the now overridden <code>all</code> method to pull the data out.</p>
  
  <p>I'm looking for a more concrete way to modify the data within my form request that doesn't require the calling of a specific method.</p>
  
  <p>Cheers</p>