title: laravel Undefined offset: 0
body: <p>I am trying to diplay an error mesasge in case the field selected is duplicated in db.For this I am using laravel validation required unique. I am having problem with redirect
  Here is store controller</p>
  
  <pre><code> public function store() {
          $rules = array(
              'car' =&gt; array('required', 'unique:insur_docs,car_id'),
          );
  
          $validation = Validator::make(Input::all(), $rules);
  
          if ($validation-&gt;fails()) {
              // Validation has failed.
              return Redirect::to('insur_docs/create')-&gt;with_input()-&gt;with_errors($validation);
          } else {
              $data = new InsurDoc();
              $data-&gt;ownership_cert = Input::get('ownership_cert');
              $data-&gt;authoriz = Input::get('authoriz');
              $data-&gt;drive_permis = Input::get('drive_permis');
              $data-&gt;sgs = Input::get('sgs');
              $data-&gt;tpl = Input::get('tpl');
              $data-&gt;kasko = Input::get('kasko');
              $data-&gt;inter_permis = Input::get('inter_permis');
              $data-&gt;car_id = Input::get('car');
              $data-&gt;save();
              // redirect
              return Redirect::to('/');
          }
      }
  </code></pre>
  
  <p>Here is the route</p>
  
  <pre><code>Route::get('insur_docs/create', array('as' =&gt; 'insur_docs.create','uses' =&gt; 'Insur_DocController@create'));
  </code></pre>
  
  <p>create controller</p>
  
  <pre><code>public function create() {
  
  
       $cars = DB::table('cars')-&gt;orderBy('Description', 'asc')-&gt;distinct()-&gt;lists('Description', 'id');
          return View::make('pages.insur_docs_create', array(
                      'cars' =&gt; $cars
          ));
  
  }
  </code></pre>
  
  <p>insur_docs_create.blade.php</p>
  
  <pre><code>&lt;div id="div-1" class="body"&gt;
              {{ Form::open(array('url' =&gt; 'insur_docs/store', 'class'=&gt;'form-horizontal','id'=&gt;'inline-validate')) }} 
              &lt;div class="form-group"&gt;
                  {{ Form::label('ownership_cert', 'Ownership Certificate', array('class'=&gt;'control-label col-lg-4')) }}
                  &lt;div class="col-lg-8"&gt;
                      {{ Form::select('ownership_cert', array('' =&gt; '', '1' =&gt; 'Yes', '0' =&gt; 'No'), '',  array(
                                  'data-validation' =&gt; 'required', 
                                  'data-validation-error-msg' =&gt; 'You did not enter a valid ownership certificate',
                                  'class' =&gt; 'form-control'))
                      }}
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('authoriz', 'Authorization', array('class'=&gt;'control-label col-lg-4')) }}            
                  &lt;div class="col-lg-8"&gt;
                      {{ Helpers\Helper::date('authoriz', '' , array(
                                  'data-validation' =&gt; 'required', 
                                  'data-validation-error-msg' =&gt; 'You did not enter a valid authorization date',
                                  'class' =&gt; 'form-control')) 
                      }}
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('drive_permis', 'Drive Permission', array('class'=&gt;'control-label col-lg-4')) }}
                  &lt;div class="col-lg-8"&gt;
                      {{ Form::select('drive_permis', array('' =&gt; '', '1' =&gt; 'Active', '0' =&gt; 'Not active'),  '',  array(
                                  'data-validation' =&gt; 'required', 
                                  'data-validation-error-msg' =&gt; 'You did not enter a valid drive permission',
                                  'class' =&gt; 'form-control'))
                      }}
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('sgs', 'SGS', array('class'=&gt;'control-label col-lg-4')) }}
                  &lt;div class="col-lg-8"&gt;
                      {{ Helpers\Helper::date('sgs', '' , array(
                                  'data-validation' =&gt; 'required', 
                                  'data-validation-error-msg' =&gt; 'You did not enter a valid sgs date',
                                  'class' =&gt; 'form-control')) 
                      }}
                  &lt;/div&gt;
              &lt;/div&gt;  
              &lt;div class="form-group"&gt;
                  {{ Form::label('tpl', 'TPL', array('class'=&gt;'control-label col-lg-4')) }}
                  &lt;div class="col-lg-8"&gt;
                      {{ Helpers\Helper::date('tpl', isset($v-&gt;sgs) ? $v-&gt;sgs : '' , array(
                                  'data-validation' =&gt; 'required', 
                                  'data-validation-error-msg' =&gt; 'You did not enter a valid tpl date',
                                  'class' =&gt; 'form-control')) 
                      }}
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('kasko', 'Kasko', array('class'=&gt;'control-label col-lg-4')) }}
                  &lt;div class="col-lg-8"&gt;
                      {{ Helpers\Helper::date('kasko', isset($v-&gt;kasko) ? $v-&gt;kasko : '' , array(
                                  'data-validation' =&gt; 'required', 
                                  'data-validation-error-msg' =&gt; 'You did not enter a valid kasko date',
                                  'class' =&gt; 'form-control')) 
                      }}
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('inter_permis', 'International Permission', array('class'=&gt;'control-label col-lg-4')) }}
                  &lt;div class="col-lg-8"&gt;
                      {{ Helpers\Helper::date('inter_permis', '' , array(
                                  'data-validation' =&gt; 'required', 
                                  'data-validation-error-msg' =&gt; 'You did not enter a valid international permission date',
                                  'class' =&gt; 'form-control')) 
                      }}
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  {{ Form::label('car', 'Car', array('class'=&gt;'control-label col-lg-4')) }}
                  &lt;div class="col-lg-8"&gt;
                      {{ Form::select('car', $cars, Input::old('class'), array(
                                  'data-validation' =&gt; 'required',  
                                  'data-validation-error-msg' =&gt; 'You did not enter a valid car',
                                  'class' =&gt; 'form-control')) 
                      }}
                      {{ $errors-&gt;first('car') }}
                  &lt;/div&gt;
              &lt;/div&gt;
              {{ Form::submit('Save', array('class' =&gt; 'btn btn-success btn-line')) }}
              &lt;input type="button" value="Back" class="btn btn-danger btn-line" onClick="history.go(-1);
                      return true;"&gt;
              &lt;div&gt;
                  @foreach($errors as $error)
                  &lt;li&gt;{{$error}}&lt;/li&gt;
                  @endforeach
              &lt;/div&gt;
              {{ Form::close() }}
  </code></pre>
  
  <p>I t displays this error : </p>
  
  <blockquote>
    <p>Undefined offset: 0</p>
  </blockquote>