title: Redirect back with errors and input in custom request class : Laravel 5
body: <p>I had some original code that shows like below with form validation and saving process in MySQL Database.</p>
  
  <p><strong>Original Code</strong></p>
  
  <pre><code>public function store(Request $request)
  {
      $v = \Validator::make($request-&gt;all(), [
          'Category' =&gt; 'required|unique:tblcategory|max:25|min:5'
      ]);
  
      if ($v-&gt;fails()) {
          return \Redirect::back()
                      -&gt;withErrors($v)
                      -&gt;withInput();
      }
      ...
      //code to save the record in database is here....
      ...
  }
  </code></pre>
  
  <p><strong><a href="http://slashnode.com/mastering-form-validation-laravel-5/" rel="nofollow">Then I followed this article</a></strong> and modified the above function and now it looks like below.</p>
  
  <pre><code>public function store(CategoryRequest $request)
  {
  
      ...
      //code to save the record in database is here....
      ...
  }
  </code></pre>
  
  <p><strong>and below is the Request class</strong></p>
  
  <pre><code>class CategoryRequest extends Request
  {
      protected $redirect = \Redirect::back()-&gt;withErrors($v)-&gt;withInput();
      public function authorize()
      {
          return false;
      }
      public function rules()
      {
          return [
              'Category' =&gt; 'required|unique:tblcategory|max:25|min:5'
          ];
      }
  }
  </code></pre>
  
  <p><strong>Error Details</strong></p>
  
  <blockquote>
    <p>syntax error, unexpected '(', expecting ',' or ';'</p>
  </blockquote>
  
  <p>This error is coming at below line.</p>
  
  <pre><code>protected $redirect = \Redirect::back()-&gt;withErrors($v)-&gt;withInput();
  </code></pre>
  
  <p>Am I missing something ?</p>