/**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $oldStok = StokProduk::all();
     $oldStokKey = array_column($oldStok->toArray(), 'produk_id');
     $produks = Produk::stok()->orderBy('produks.id')->get();
     foreach ($produks as $produk) {
         if (in_array($produk->id, $oldStokKey)) {
             StokProduk::where('produk_id', $produk->id)->update(['stok' => $produk->sisa_stok]);
         } else {
             StokProduk::create(['produk_id' => $produk->id, 'stok' => $produk->sisa_stok]);
         }
     }
 }
 public function showTest(Request $request)
 {
     $action = $request->get('act') ? $request->get('act') : 'bahan';
     $action = strtolower($action);
     if ($action == 'produk') {
         return \App\Produk::stok()->orderBy('produks.id')->get();
     } elseif ($action == 'bahan') {
         return \App\Bahan::stok()->orderBy('bahans.id')->get();
     } else {
         abort(404);
     }
 }