public function postUploadExcel(Request $request)
 {
     $validator = \Validator::make($request->all(), ['format1' => 'required']);
     if ($validator->fails()) {
         \Session::flash('alert-warning', 'Upload File ZPC dengan format CSV');
         return redirect()->back();
     }
     $file = $request->file('format1');
     if (Schema::hasTable('sap_')) {
         Schema::drop('sap_');
     }
     $file_csv = fopen($file->getPathName(), 'r');
     $header = fgetcsv($file_csv, ',');
     $header = $this->renameData($header);
     $header = $this->cekDuplicate($header);
     //        dd($header);
     if (!Schema::hasTable('sap_')) {
         Schema::create('sap_', function (Blueprint $table) use($header) {
             $table->increments('id');
             $rep = [' ', '.'];
             foreach ($header as $key => $value) {
                 $val = str_replace($rep, '_', $value);
                 $table->string(strtolower($val))->nullable();
             }
         });
     }
     $count = 0;
     while ($line = fgetcsv($file_csv, ',')) {
         $count++;
         for ($i = 0; $i < count($header); $i++) {
             if ($line[$i] === '') {
                 $line[$i] = null;
             }
             $data[$header[$i]] = $line[$i];
         }
         DB::table('sap_')->insert($data);
     }
     $storage1['lokasi_file'] = "file_zpc";
     $storage['file_name'] = $file->getClientOriginalName();
     $storage['jumlah_row'] = $count + 1;
     $storage['status'] = 'A';
     $storage['created_by'] = Auth::user()->id;
     //        $cek = Saplog::where('file_name',  $storage['file_name'])->firstOrFail();
     //        if ($cek){
     //            $storage['file_name']= $storage['file_name'].'_rev1.csv';
     //        }
     Saplog::where('status', 'A')->update(array('status' => 'N'));
     Saplog::create($storage);
     Storage::disk('local')->put($storage1['lokasi_file'] . '/' . $storage['file_name'], File::get($file));
     return redirect('hrga/view-upload-data');
 }