Ejemplo n.º 1
0
 public function productIndex()
 {
     // Get products
     $products = \Product::Find(['limit' => 9, 'featured' => 1, 'status' => 1]);
     // Get collections
     $collections = \Collection::Find(['status' => 1]);
     // Get currencies
     $currencies = \Currency::Find(['status' => 1]);
     return view('example.product-index', ['products' => $products['result'], 'collections' => $collections['result'], 'currencies' => $currencies['result']]);
 }
Ejemplo n.º 2
0
 /**
  * Submit excel file to database.
  *
  * @return Response
  */
 public function upload()
 {
     $all = Request::all();
     $file = $all['file'];
     $table = ExcelHelper::import($file);
     foreach ($table as $key => $value) {
         foreach ($value as $j => $k) {
             if ($k === null) {
                 $value[$j] = '';
             }
         }
         $akun = Akun::find(['no_akun' => $value['no_akun']])->first();
         if ($akun == null) {
             $akun = new Akun();
             /* fill mata_uang */
             $mata_uang = Currency::find($value['mata_uang']);
             if ($mata_uang == null) {
                 continue;
             }
             $value['mata_uang'] = $mata_uang->simbol;
             /* fill tipe akun */
             $id_tipeakun = $value['id_tipeakun'];
             $tipeakun = TipeAkun::find($id_tipeakun);
             if ($tipeakun == null) {
                 $id_tipeakun = ucwords(strtolower($id_tipeakun));
                 $tipeakun = TipeAkun::firstOrCreate(['nama' => $id_tipeakun]);
                 $id_tipeakun = $tipeakun->id;
             }
             $value['id_tipeakun'] = $id_tipeakun;
             /* fill saldo awal */
             if (!is_numeric($value['saldo_awal'])) {
                 $value['saldo_awal'] = 0;
             }
             /* fill tanggal */
             if ($value['tanggal'] == null) {
                 $value['tanggal'] = date('Y-m-d');
             } else {
                 $tanggal = $value['tanggal'];
                 $tanggal = date('Y-m-d', strtotime($tanggal));
                 $value['tanggal'] = $tanggal;
             }
             /* finally */
             $akun->fill($value);
             $akun->save();
             // dd($akun);
         }
         //dd($akun);
         // $akun = Akun::firstOrCreate(['no_akun' => $value['no_akun']]);
         //$akun
     }
     return redirect('akun');
 }