2016-12-06 1 views
0

Hallo blitzen ich die folgende Form haben:Laravel 5.3, wenn die Validierung Sitzung fehl nichts

 <form action="{{ route('postCustomerInfo') }}" method="post" class="shipping-form"> 
      {{ csrf_field() }} 
      <input type="hidden" name="note" value="hidden_note_field"> 
      <input type="hidden" name="country_id" value="1"> 
       <div class="form-checkout"> 
       <div class="form-fields"> 
        @if($errors->has('name'))<div class="input-box error" data-error="{{ $errors->first('name') }}"> 
         @else<div class="input-box"> 
        @endif 
         <input type="text" name="name" value={{ old('name') }}> 
         <label for="">name</label> 
        </div> 
        @if($errors->has('phone'))<div class="input-box error" data-error="{{ $errors->first('phone') }}"> 
         @else <div class="input-box"> 
        @endif 
         <input type="text" name="phone" value={{ old('phone') }} onkeypress='return event.charCode >= 48 && event.charCode <= 57'> 
         <label for="">phone</label> 
        </div> 
        @if($errors->has('email'))<div class="input-box error" data-error="{{ $errors->first('email') }}"> 
         @else <div class="input-box"> 
        @endif 
         <input type="text" name="email" value="{{ old('email') }}"> 
         <label for="">email</label> 
        </div> 
        <div class="row"> 
         <div class="col-xs-5 col-sm-5 col-md-6"> 
          @if($errors->has('city'))<div class="input-box error" data-error="{{ $errors->first('city') }}"> 
           @else<div class="input-box"> 
          @endif 
           <input type="text" name="city" value="{{ old('city') }}"> 
           <label for="">city</label> 
          </div> 
         </div> 
         <div class="col-xs-7 col-sm-7 col-md-6"> 
          @if($errors->has('postal_code'))<div class="input-box error" data-error="{{ $errors->first('postal_code') }}"> 
           @else<div class="input-box error" data-error="{{ $errors->first('postal_code') }}"> 
          @endif 
           <input type="text" name="postal_code" value="{{ old('postal_code') }}"> 
           <label for="">postal code</label> 
          </div> 
         </div> 
        </div> 
        @if($errors->has('address_line'))<div class="input-box error" data-error="{{ $errors->first('address_line') }}"> 
         @else<div class="input-box error" data-error="{{ $errors->first('address_line') }}"> 
        @endif 
         <input type="text" name="address_line" value={{ old('address_line') }}> 
         <label for="">address</label> 
        </div> 
       </div> 
      </div> 
     </form> 
     <a href="" class="btn action">Go to <span>shipping</span></a> 

ich senden Sie das Formular über jquery

$(document).ready(function() { 
     $('.btn.action').on('click','',function (e) { 
      e.preventDefault(); 
      var $form = $('form.shipping-form'); 
      $form.submit(); 
     }); 
    }); 

und meine FormRequest Klasse ist:

class CustomerInformationRequest extends FormRequest { 
/** 
* Determine if the user is authorized to make this request. 
* 
* @return bool 
*/ 
public function authorize() { 
    return true; 
} 

/** 
* Get the validation rules that apply to the request. 
* 
* @return array 
*/ 
public function rules() { 
    return [ 
     'name'   => 'required|min:5|max:50', 
     'email'   => 'required|email|min:5|max:50', 
     'phone'   => 'required|min:3|max:20', 
     'country_id' => 'required', 
     'city'   => 'required|min:3', 
     'postal_code' => 'required|digits:4', 
     'address_line' => 'required|min:5|max:50', 
     'note'   => '' 
    ]; 
} 

}

Ich lese diesen Thread in StackOverflow: Laravel 5 input old is empty Aber ich glaube nicht, dass das mein Problem tatsächlich ist.Und noch meine {{alt ('Werte')}} sind leer und ich weiß nicht warum? Irgendwelche Ideen?

+0

haben Sie Anfrage in Ihre Controller-Methode mit CustomerInformationRequest $ Anfrage injiziert? –

+0

Ja! öffentliche Funktion customerInformation (CustomerInformationRequest $ -Anfrage) { Session :: put ('checkout.customer_information', $ request-> input()); } – deshi

+0

auch in meiner Sitzung kann ich _old_input Schlüssel nicht sehen, wenn ich dd in der Klinge, nachdem ich das Formular senden – deshi

Antwort

0
/** 
* The application's global HTTP middleware stack. 
* 
* These middleware are run during every request to your application. 
* 
* @var array 
*/ 
protected $middleware = [ 
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, 
]; 

/** 
* The application's route middleware groups. 
* 
* @var array 
*/ 
protected $middlewareGroups = [ 
    'web' => [ 
     \App\Http\Middleware\EncryptCookies::class, 
     \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 
     \Illuminate\Session\Middleware\StartSession::class, 
     \Illuminate\View\Middleware\ShareErrorsFromSession::class, 
     \App\Http\Middleware\VerifyCsrfToken::class, 
     \Illuminate\Routing\Middleware\SubstituteBindings::class, 
     \App\Http\Middleware\BeforeAutoTrimmer::class 
    ], 

    'api' => [ 
     'throttle:60,1', 
     'bindings', 
    ], 
]; 

/** 
* The application's route middleware. 
* 
* These middleware may be assigned to groups or used individually. 
* 
* @var array 
*/ 
protected $routeMiddleware = [ 
    'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 
    'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 
    'can' => \Illuminate\Auth\Middleware\Authorize::class, 
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 
    'setCurrency'=>\App\Http\Middleware\SetCurrency::class, 
    'checkout'=>\App\Http\Middleware\Checkout::class, 
];}`. 

Ich habe \App\Http\Middleware\BeforeAutoTrimmer::class, der alle meine Formen zu schneiden pflegt: public function handle($request, Closure $next) { $request->merge(array_map('trim', $request->all())); return $next($request); } , diese 'setCurrency'=>\App\Http\Middleware\SetCurrency::class die Währung von Datenbank-Sitzung zu setzen pflegt:

`public function handle ($ request, Closure $ weiter) { if (! Session :: hat ('currency')) { $ currency = Einstellung :: where ('setting_name', 'currency') -> select ('setting_value as code') -> first() ; $ currencyData = Währung :: where ('code', $ currency-> code) -> select ('symbol_position', 'symbol', 'code') -> first();

 Session::put('currency', $currencyData); 
     Session::save(); 
     return $next($request); 
    } 
    return $next($request);}` 

und 'checkout'=>\App\Http\Middleware\Checkout::class, wen interessiert mich neu auszurichten Warenkorb in Sitzung ist leer:

`public function handle ($ request, Closure $ next) {

if(!Session::has('cart')){ 
     return redirect()->route('home'); 
    } 
    return $next($request); 
}` 

Aber der Rest I denke, sie sind Standard für Laravel und ich habe sie nicht berührt

Verwandte Themen