title: Laravel - Redirect to a route POST
body: <p>I've tried to redirect my POSTform if validator fails, but it does not work because it's not a GET route.
  I've a first page for choose a product, post to second page for add one model to the product.
  I'want to redirect to the 2nd page if validator fails.</p>
  
  <p><strong>Validation</strong>:</p>
  
  <pre><code>if ($validator-&gt;fails()) {
          return redirect('admin/modele/create')
               -&gt;withErrors($validator)
               -&gt;withInput();
  }
  </code></pre>
  
  <p><strong>Routes:</strong></p>
  
  <pre><code>Route::get('modele/select/product', 'ModeleController@selectProduct')-&gt;name('modele.selectProduct'); //get page for select product
  Route::post('modele/selected/product', 'ModeleController@selectedProduct')-&gt;name('modele.selectedProduct');  //the product is selected, send it to form page
  Route::post('modele/create/product/{produit}', 'ModeleController@storea')-&gt;name('modele.storea'); //is a store custom
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>public function selectProduct() 
      {
          //
            $lesProduits = Produit::pluck('nom', 'id');
            return view('admin/modele/select', compact('lesProduits'));
  
      }
  
       public function selectedProduct(Request $request) 
      {
          //
  
              $unProduit = $request-&gt;get('produit');
              $id = ($request-&gt;get('produit'));
  
              $unProduit = Produit::where('id', $id)-&gt;pluck('nom', 'id');
              $uneCategorie = Produit::find($id)-&gt;categorie;
              $produit = Produit::find($id);
             //dd($uneCategorie)   ;
              //$categorie = $unProduit-&gt;categorie-&gt;id;
  
              return view('admin/modele/create', compact('unProduit', 'uneCategorie', 'produit'));
  
      }
  public function storea(Request $request, $produit_id)
      {
          //
          $validator = Validator::make($request-&gt;all(), [
              'ref' =&gt; 'required|max:255',
              'prixHT' =&gt; 'required|max:9|numeric',
              'prixHTpromo' =&gt; 'max:9|numeric',
              'quantite' =&gt; 'required|numeric|max:255',
              't1' =&gt; 'max:255',
               't2' =&gt; 'max:255',
               't3' =&gt; 'max:255',
               't4' =&gt; 'max:255',
               't5' =&gt; 'max:255',
               't6' =&gt; 'max:255',
               't7' =&gt; 'max:255',
               't8' =&gt; 'max:255',
               't9' =&gt; 'max:255',
               't10' =&gt; 'max:255',
              'image' =&gt; 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
  
          ]);
  
          if ($validator-&gt;fails()) {
               return redirect('admin/modele/create')
                          -&gt;withErrors($validator)
                          -&gt;withInput();
          }
          else
          {        
              $unModele = New Modele();
              $unModele-&gt;produit_id = $produit_id;
              $unModele-&gt;ref = $request-&gt;get('ref');
              $unModele-&gt;prixHT = $request-&gt;get('prixHT');
              if ($request-&gt;get('prixHTpromo') != null)
              {
                 $unModele-&gt;prixHPromoHT = $request-&gt;get('prixHTpromo');   
              }      
              $unModele-&gt;quantiteDebut = $request-&gt;get('quantite');
              for ($i = 1; $i &lt; 11; $i++)
              {
                  $name = 't'.$i;
                  $nameDB = 'info'.$i;
                  if ($request-&gt;get($name) != null)
                  {
                      $unModele-&gt;$nameDB = $request-&gt;get($name);
                  }
              }
              // photo 0,1             
              if($request-&gt;file('image') != null) // &amp;&amp; $uneActualite-&gt;url != null)
              {
                  //image code here
              }
              else
              {
                  $unModele-&gt;image=null;
              }
            /////////////////////////
              $unModele-&gt;save();
              $request-&gt;session()-&gt;flash("success","Modèle ajouté.");
              return redirect(route('modele.index'));        
          }
  
  
      }
  </code></pre>
  
  <p><strong>Select page:</strong></p>
  
  <pre><code>     {!! Form::open(array('route' =&gt; 'modele.selectedProduct')) !!}
  
  
                              &lt;div class="form-group"&gt;
                   {!! Form::label('produit', 'Produit') !!}
                   {!! Form::select('produit',$lesProduits, null, array('class' =&gt; 'form-control')) !!}
                              &lt;/div&gt;
                  @if ($errors-&gt;has('produit'))
                              &lt;div class="alert alert-danger" role="alert"&gt;
                                  &lt;ul&gt;
                                      @foreach ($errors-&gt;get('produit') as $message) 
                                          &lt;li&gt;{{$message}}&lt;/li&gt;
                                      @endforeach
                                  &lt;/ul&gt;
                              &lt;/div&gt;
                              @endif
  
  
  
  
                              &lt;button type="submit" class="btn btn-primary col-lg-12"&gt;&lt;span class="glyphicon glyphicon-ok" aria-hidden="true"&gt;&lt;/span&gt;&lt;/button&gt;
                              {!! Form::close() !!}
  </code></pre>
  
  <p><strong>Create model page:</strong></p>
  
  <pre><code>                    {!! Form::open(array('route' =&gt; ['modele.storea', $produit-&gt;id],'enctype' =&gt; 'multipart/form-data')) !!}
  
  
                      &lt;div class="form-group"&gt;
           {!! Form::label('produit', 'Produit') !!}
           {!! Form::select('produit', $unProduit, null, array('class' =&gt; 'form-control')) !!}
                      &lt;/div&gt;
          @if ($errors-&gt;has('produit'))
                      &lt;div class="alert alert-danger" role="alert"&gt;
                          &lt;ul&gt;
                              @foreach ($errors-&gt;get('produit') as $message) 
                                  &lt;li&gt;{{$message}}&lt;/li&gt;
                              @endforeach
                          &lt;/ul&gt;
                      &lt;/div&gt;
                      @endif
  
                      &lt;div class="form-group"&gt;
                      {!! Form::label('ref', 'Réference') !!}
                      {!! Form::text('ref', null,array('maxlength' =&gt; 255, 'class'=&gt;'form-control' )) !!}                        
                      &lt;/div&gt;                        
                      @if ($errors-&gt;has('ref'))
                      &lt;div class="alert alert-danger" role="alert"&gt;
                          &lt;ul&gt;
                      @foreach ($errors-&gt;get('ref') as $message) 
                          &lt;li&gt;{{$message}}&lt;/li&gt;
                      @endforeach
                      &lt;/ul&gt;
                      &lt;/div&gt;
                      @endif
  @for ($i = 1; $i &lt; 11; $i++)
                                  &lt;?php $item_name = 't' . $i; ?&gt;
  
                                  @if ($uneCategorie-&gt;$item_name != null)
                                      &lt;div class="col-lg-3"&gt;
                                          &lt;div class="form-group"&gt;
                                           {!! Form::label($item_name, $uneCategorie-&gt;$item_name) !!}
                                           {!! Form::text($item_name, null,array('maxlength' =&gt; 255, 'class'=&gt;'form-control' )) !!}                        
                                           &lt;/div&gt;                        
                                           @if ($errors-&gt;has('{{$item_name }}'))
                                           &lt;div class="alert alert-danger" role="alert"&gt;
                                               &lt;ul&gt;
                                           @foreach ($errors-&gt;get('{{$item_name }}') as $message) 
                                               &lt;li&gt;{{$message}}&lt;/li&gt;
                                           @endforeach
                                           &lt;/ul&gt;
                                           &lt;/div&gt;
                                           @endif
                                      &lt;/div&gt;
                                  @endif                                            
                              @endfor 
  </code></pre>