title: Error "array_key_exists(): The first argument should be either a string or an integer"
body: <p>I'm using Laravel for my project, and I need to generate no_track from the <code>id</code> of the record, <code>created_at-&gt;hour</code> and <code>created_at-&gt;minute</code>. I can save the data to the database, but I can't save the data to the database after creating the <code>no_track</code>. The error messages said:</p>
  
  <blockquote>
    <p>array_key_exists(): The first argument should be either a string or an
    integer.</p>
  </blockquote>
  
  <p>I attached an image of the error message. When I save the data to the database I want to get <code>no_track</code> from the <code>id</code> of the record, hour and minute and save the <code>no_track</code> to the <code>no_track</code> field.</p>
  
  <p><a href="https://i.stack.imgur.com/qivxe.png" rel="nofollow noreferrer">I got this error messages</a></p>
  
  <p>This my form code:</p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;div class="col-md-8 col-md-offset-2"&gt;
          &lt;div class="panel panel-default"&gt;
              &lt;div class="panel-heading" style="background-color: #2a3b48; color: #ffffff"&gt;&lt;center&gt;Entri Data Gangguan&lt;/center&gt;&lt;/div&gt;
              &lt;div class="panel-body"&gt;
                  &lt;form class="form-horizontal" role="form" method="POST" action="{{ route('lapor.submit') }}"&gt;
  
                      {{ csrf_field() }}
  
                      &lt;div class="form-group{{ $errors-&gt;has('id_jenis') ? ' has-error' : '' }}"&gt;
                          &lt;label for="id_jenis" class="col-md-4 control-label"&gt;Jenis Gangguan&lt;/label&gt;
  
                          &lt;div class="col-md-6"&gt;
                              &lt;select name="id_jenis" id="id_jenis" class="form-control jgangguan" value="{{ old('id_jenis') }}" required&gt;
                                  &lt;option disabled="true" selected="true"&gt;- Pilihan -&lt;/option&gt;
                              @forelse($jgangguan as $jgangguan)
                                      &lt;option value="{{ $jgangguan-&gt;id }}"&gt;{{ $jgangguan-&gt;nama_layanan }}&lt;/option&gt;
                                  @empty
  
                                  @endforelse
                              &lt;/select&gt;
                              @if ($errors-&gt;has('id_jenis'))
                                  &lt;span class="help-block"&gt;
                                  &lt;strong&gt;{{ $errors-&gt;first('id_jenis') }}&lt;/strong&gt;
                              &lt;/span&gt;
                              @endif
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group{{ $errors-&gt;has('id_app_jar') ? ' has-error' : '' }} cgangguan"&gt;
                          &lt;label for="id_app_jar" class="col-md-4 control-label"&gt;&lt;/label&gt;
  
                          &lt;div class="col-md-6"&gt;
                              &lt;select name="id_app_jar" id="id_app_jar" class="form-control jappjar" value="{{ old('id_app_jar') }}" required&gt;
                                  &lt;option value="0" disabled selected&gt;- Pilihan -&lt;/option&gt;
                              &lt;/select&gt;
  
                              @if ($errors-&gt;has('id_app_jar'))
                                  &lt;span class="help-block"&gt;
                                  &lt;strong&gt;{{ $errors-&gt;first('id_app_jar') }}&lt;/strong&gt;
                              &lt;/span&gt;
                              @endif
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group{{ $errors-&gt;has('detail') ? ' has-error' : '' }}"&gt;
                          &lt;label for="detail" class="col-md-4 control-label"&gt;&lt;/label&gt;
  
                          &lt;div class="col-md-6"&gt;
                              &lt;textarea name="detail" id="detail" class="form-control" value="{{ old('detail') }}" placeholder="Detail Gangguan"&gt;
  
                              &lt;/textarea&gt;
  
                              @if ($errors-&gt;has('detail'))
                                  &lt;span class="help-block"&gt;
                                  &lt;strong&gt;{{ $errors-&gt;first('detail') }}&lt;/strong&gt;
                              &lt;/span&gt;
                              @endif
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group"&gt;
                          &lt;div class="col-md-6 col-md-offset-4"&gt;
                              &lt;button type="submit" class="btn btn-danger col-md-3"&gt;
                                  Lapor
                              &lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
  
                  &lt;script src="{{ url('/assets/vendor/jquery/jquery.min.js') }}"&gt;&lt;/script&gt;
                  &lt;script type="text/javascript"&gt;
                      $(document).ready(function () {
                          $(document).on('change','.jgangguan', function () {
                              //console.log('its change');
  
                              var id_jenis=$(this).val();
                              //console.log(id_jenis);
                              var div=$(this).parents();
                              var op="";
  
                              switch (id_jenis){
                                  case '1' :
                                      $.ajax({
                                          type:'get',
                                          url:'{!! URL::to('data-jar') !!}',
                                          data:{'id':id_jenis},
                                          success:function (data) {
                                              //console.log('success');
                                              //console.log(data);
                                              //console.log(data);
                                              op+='&lt;option value="0" selected disabled&gt;- Pilih Jaringan -&lt;/option&gt;';
                                              for(i=0;i&lt;data.length;i++){
                                                  op+='&lt;option value="'+data[i].id+'"&gt;'+data[i].nama_jaringan+'&lt;/option&gt;';
                                              }
                                              div.find('.jappjar').html("");
                                              div.find('.jappjar').append(op);
                                          },
                                          error:function () {
  
                                          }
                                      });
                                  break;
  
                                  case '2' :
                                      $.ajax({
                                          type:'get',
                                          url:'{!! URL::to('data-app') !!}',
                                          data:{'id':id_jenis},
                                          success:function (data) {
                                              //console.log('success');
                                              //console.log(data);
                                              //console.log(data);
                                              op+='&lt;option value="0" selected disabled&gt;- Pilih Aplikasi -&lt;/option&gt;';
                                              for(i=0;i&lt;data.length;i++){
                                                  op+='&lt;option value="'+data[i].id+'"&gt;'+data[i].nama+'&lt;/option&gt;';
                                              }
                                              div.find('.jappjar').html("");
                                              div.find('.jappjar').append(op);
  
                                          },
                                          error:function () {
  
                                          }
                                      });
                                  break;
                              }
  
                          });
                      });
                  &lt;/script&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This my controller:</p>
  
  <pre><code>/**
   * Show the form for creating a new resource.
   *
   * @return \Illuminate\Http\Response
   */
  public function create()
  {
      $jgangguan = JenisLayanan::all();
      $app = Aplikasi::all();
      $jar = Jaringan::all();
      return view('lapor.create', compact('jgangguan','app','jar'));
  }
  
  /**
   * Store a newly created resource in storage.
   *
   * @param  \Illuminate\Http\Request  $request
   * @return \Illuminate\Http\Response
   */
  public function store(Request $request)
  {
      $this-&gt;validate($request,[
          'id_jenis' =&gt; 'required',
          'id_app_jar' =&gt;'required'
      ]);
  
      //$status = Status::all();
      $status = 1;
      $codeH = substr(strftime("%H", time()),0);
      $codeM = substr(strftime("%M", time()),0);
      $codeS = substr(strftime("%S", time()),0);
      $id = Auth::user()-&gt;id;
      $id_app_jar = $request-&gt;id_app_jar;
      $id_jenis = $request-&gt;id_jenis;
  
      $gangguan = new Gangguan();
      $gangguan-&gt;id_pelapor = $id;
      $gangguan-&gt;id_jenis = $id_jenis;
      $gangguan-&gt;id_aplikasi_atau_jaringan = $id_app_jar;
      $gangguan-&gt;detail = $request-&gt;detail;
      $gangguan-&gt;id_status = $status;
      $gangguan-&gt;no_track = $codeH.$codeM;
      $gangguan-&gt;save();
  
      $id = $gangguan-&gt;id;
      $jam = $gangguan-&gt;created_at-&gt;hour;
      $menit = $gangguan-&gt;created_at-&gt;minute;
      $track = $id.$jam.$menit;
      $gangguan = Gangguan::findOrFail($id);
      $gangguan-&gt;update(array(
          $gangguan-&gt;no_track = $track
      ));
  
      return redirect()
          -&gt;route('dashboard')
          -&gt;with('message',$track);
  }
  
  /**
   * Display the specified resource.
   *
   * @param  int  $id
   * @return \Illuminate\Http\Response
   */
  public function show($id)
  {
      //
  }
  
  /**
   * Show the form for editing the specified resource.
   *
   * @param  int  $id
   * @return \Illuminate\Http\Response
   */
  public function edit($id)
  {
      //
  }
  
  /**
   * Update the specified resource in storage.
   *
   * @param  \Illuminate\Http\Request  $request
   * @param  int  $id
   * @return \Illuminate\Http\Response
   */
  public function update(Request $request, $id)
  {
      //
  }
  
  /**
   * Remove the specified resource from storage.
   *
   * @param  int  $id
   * @return \Illuminate\Http\Response
   */
  public function destroy($id)
  {
      //
  }
  
  public function dataJar(){
      $jar = Jaringan::all();
      return response()-&gt;json($jar);
  }
  
  public function dataApp(){
      $app = Aplikasi::all();
      return response()-&gt;json($app);
  }
  </code></pre>
  
  <p>This my table structure:</p>
  
  <p><a href="https://i.stack.imgur.com/jurwA.png" rel="nofollow noreferrer">Table structure</a></p>