コード例 #1
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('tipeakuns', function (Blueprint $table) {
         $table->increments('id');
         $table->string('nama');
         $table->string('normal');
     });
     TipeAkun::create(['nama' => 'Ekuitas']);
 }
コード例 #2
0
 /**
  * Get an excel table export.
  *
  * @return Response
  */
 public function export()
 {
     $tipeakun = new TipeAkun();
     $tipeakuns = $tipeakun->get($tipeakun->getFillable());
     $tipeakuns = $tipeakuns->toArray();
     if ($tipeakuns == []) {
         return view('tipeakun.export');
     }
     return ExcelHelper::export($tipeakuns, 'tipeakuns');
 }
コード例 #3
0
ファイル: AkunController.php プロジェクト: ibnoe/trustline
 /**
  * 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');
 }