public function store_item(Request $request) { $this->validation_item_rules($request); $trans_item = $request->input(); $save_trans_item = TransactionItem::create($trans_item); return redirect()->route('kasir.transaction.detail_item', $request->input('transaction_id')); }
public function store_item(Request $request) { $date_amount = $this->saved_date_format($request->input('date_amount')); $param_ac_id = $request->input('asset_categories_id'); $valid_asset = AssetCategory::where('asset_categories.id', $param_ac_id)->join('asset_types', 'asset_types.id', '=', 'asset_categories.asset_type_id')->select('asset_categories.id as ac_id', 'asset_types.code as at_code', 'asset_categories.code as ac_code')->first(); $kode_kategori = $valid_asset->ac_code; $kode_pengelompokan = $request->input('trans_gol_id'); $tahun = Carbon::now()->toDateTimeString(); $format = Carbon::parse($tahun)->format('y'); $no_urut = TransactionItem::where('asset_categories_id', $param_ac_id)->get()->count(); $before_urut = '000'; if ($no_urut > 9) { $before_urut = '000'; } elseif ($no_urut > 99) { $before_urut = '00'; } elseif ($no_urut > 999) { $before_urut = '0'; } $new_index = $kode_kategori . $kode_pengelompokan . $format . $before_urut . $no_urut + 1; $request->merge(array('date_amount' => $date_amount, 'index' => $new_index)); $transaction_item = $request->input(); $save_trans = TransactionItem::create($transaction_item); if ($request->file('url_photo') != '') { $imageName = $save_trans->id . '-barang.' . $request->file('url_photo')->getClientOriginalExtension(); $request->file('url_photo')->move(base_path() . '/public/images/transaksi/barang/', $imageName); } Session::flash('flash_message', 'Data asset berhasil ditambahkan'); return redirect()->back(); }