title: How to pass Checkbox value 0 if not checked and 1 if checked using array
body: <p>I have a checkbox when i selected i have on database the value '1' but when i dont select i have this erreur 
  {SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'actif' cannot be null (SQL: insert into <code>techniciens</code> (<code>user_id</code>, <code>actif</code>, <code>moyenne_avis</code>, <code>updated_at</code>, <code>created_at</code>) values (6, , 30.555, 2018-03-14 09:07:15, 2018-03-14 09:07:15))}</p>
  
  <p>create.blade.php</p>
  
  <pre><code>@extends('Layouts/app')
  @extends('Layouts.master')
  @section('content')
  @if(count($errors))
  
      &lt;div class="alert alert-danger" role="alert"&gt;
      &lt;ul&gt;
        @foreach($errors -&gt;all() as $message)
           &lt;li&gt;{{$message}}&lt;/li&gt;
        @endforeach
      &lt;/ul&gt;
       &lt;/div&gt;
      @endif
      &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-10"&gt;
              &lt;h1&gt;Ajouter Technicien&lt;/h1&gt;
          &lt;form action=" {{url ('technicien')  }}" method="post"&gt;
           {{csrf_field()}}
              &lt;div class="form-group"&gt;
                  &lt;label for=""&gt;Nom&lt;/label&gt;
                  &lt;input id="nom" type="text" class="form-control" name="nom" 
   value="{{ old('nom')   
              }}" required autofocus&gt;
  
                              @if ($errors-&gt;has('nom'))
                                  &lt;span class="help-block"&gt;
                                      &lt;strong&gt;{{ $errors-&gt;first('nom') }}
   &lt;/strong&gt;
                                  &lt;/span&gt;
                              @endif
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for=""&gt;Prenom&lt;/label&gt;
                  &lt;input id="prenom" type="text" class="form-control" 
   name="prenom" value="{{ 
            old('prenom') }}" required autofocus&gt;
  
                              @if ($errors-&gt;has('prenom'))
                                  &lt;span class="help-block"&gt;
                                      &lt;strong&gt;{{ $errors-&gt;first('prenom') }}
   &lt;/strong&gt;
                                  &lt;/span&gt;
                              @endif
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for=""&gt;Telephone&lt;/label&gt;
                  &lt;input id="tel" type="text" class="form-control" name="tel" 
  value="{{ old('tel') }}" 
          required autofocus&gt;
  
                              @if ($errors-&gt;has('tel'))
                                  &lt;span class="help-block"&gt;
                                      &lt;strong&gt;{{ $errors-&gt;first('tel') }}
   &lt;/strong&gt;
                                  &lt;/span&gt;
                              @endif
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for=""&gt;Mobile&lt;/label&gt;
                  &lt;input id="mobil" type="text" class="form-control" 
   name="mobil" value="{{ 
        old('mobil') }}" required autofocus&gt;
  
                              @if ($errors-&gt;has('mobile'))
                                  &lt;span class="help-block"&gt;
                                      &lt;strong&gt;{{ $errors-&gt;first('mobil') }}
   &lt;/strong&gt;
                                  &lt;/span&gt;
                              @endif
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label for=""&gt;Role&lt;/label&gt;
                  &lt;input id="role" type="text" class="form-control" 
   name="role" value="{{ old('role') }}" 
       required autofocus&gt;
  
                              @if ($errors-&gt;has('role'))
                                  &lt;span class="help-block"&gt;
                                      &lt;strong&gt;{{ $errors-&gt;first('role') }}
   &lt;/strong&gt;
                                  &lt;/span&gt;
                              @endif
              &lt;/div&gt;
              &lt;div class="form-group{{ $errors-&gt;has('email') ? ' has-error' : 
   '' }}"&gt;
                  &lt;label for=""&gt;E-Mail Address&lt;/label&gt;
                  &lt;input id="email" type="text" class="form-control" 
   name="email" value="{{ 
     old('email') }}" required autofocus&gt;
  
                              @if ($errors-&gt;has('email'))
                                  &lt;span class="help-block"&gt;
                                      &lt;strong&gt;{{ $errors-&gt;first('email') }}
   &lt;/strong&gt;
                                  &lt;/span&gt;
                              @endif
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                 &lt;label for="password"&gt;Password&lt;/label&gt;
  
                          &lt;div class="form-group"&gt;
                              &lt;input id="password" type="password" 
   class="form-control" 
       name="password" value="{{ old('password') }}" required autofocus&gt;
  
                              @if ($errors-&gt;has('password'))
                                  &lt;span class="help-block"&gt;
                                      &lt;strong&gt;{{ $errors-&gt;first('password') }}
    &lt;/strong&gt;
                                  &lt;/span&gt;
                              @endif
                          &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                 &lt;label for="password"&gt;Confirm Password&lt;/label&gt;
                          &lt;div class="form-group"&gt;
                              &lt;input id="password_confirmation" 
   type="password" class="form-control" 
      name="password" value="{{ old('password_confirmation') }}" required 
   autofocus&gt;
                          &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for="zoneintervention"&gt;zoneintervention&lt;/label&gt;
                  &lt;select multiple name="zoneintervention_id[]" 
     id="zoneintervention" class="form-
      control" &gt;
  
                          @foreach($zoneintervention as $zoneintervention)
                           &lt;option value="{{ $zoneintervention-&gt;id }}"&gt;
                              {{$zoneintervention-&gt;code_postal}}
                           &lt;/option&gt;
                          @endforeach
                  &lt;/select&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;label for=""&gt;Moyenne Avis&lt;/label&gt;
                   &lt;input type="text"  name ="moyenne_avis" class="form-
    control"value="
      {{old('moyenne_avis')}}"&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;div class="form-group"&gt;
                  &lt;label for=""&gt;Etat&lt;/label&gt;
                  &lt;input type="checkbox"  name ="actif" value="1"&gt;
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;input type="submit" value = "suivant" class="form-control 
   btn btn-primary"&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  @endsection
  </code></pre>
  
  <p>controler</p>
  
  <pre><code> public function create()
   {
       $zoneintervention = Zoneintervention::orderBy('id', 'desc')-&gt;get();
      $metier = metier::orderBy('libelle_metier', 'desc')-&gt;get();
      $tache = tache::orderBy('libelle_tache', 'desc')-&gt;get();
      $user = user::orderBy('id', 'desc')-&gt;get();
  
      return view('technicien.create')-&gt;with('zoneintervention', 
     $zoneintervention)-&gt;with('user', 
      $user);
  
    }
    /**
    * Store a newly created resource in storage.
    *
       * @param  
       * @return \Illuminate\Http\Response
       */
      public function store(Request $request)
   {
      $user = new user();
      $user-&gt;nom = $request-&gt;input('nom');
      $user-&gt;prenom = $request-&gt;input('prenom');
      $user-&gt;tel = $request-&gt;input('tel');
      $user-&gt;mobil = $request-&gt;input('mobil');
      $user-&gt;role = $request-&gt;input('role');
      $user-&gt;email = $request-&gt;input('email');
      $user-&gt;password = $request-&gt;input('password');
      $user-&gt;save();
  
      $technicien = new technicien();
      $technicien-&gt;user_id = $user-&gt;id;
      $technicien-&gt;actif = $request-&gt;input('actif');
      $technicien-&gt;moyenne_avis = $request-&gt;input('moyenne_avis');
      $technicien-&gt;save();
      $technicien-&gt;zoneintervention()-&gt;attach($request-&gt;zoneintervention_id);
  
  
  
      return redirect('tarification/create');
  
  }
  </code></pre>
  
  <p>route.php</p>
  
  <pre><code>Route::get('/technicien', 'TechnicienController@index');
  Route::get('/technicien/create', 'TechnicienController@create');
  Route::post('/technicien', 'TechnicienController@store');
  </code></pre>