public function get_data_detail_item($id)
 {
     $transaction = Transaction::where('transactions.id', '=', $id)->join('customers', 'transactions.customer_id', '=', 'customers.id')->join('users', 'transactions.user_id', '=', 'users.id')->select('transactions.*', 'customers.name', 'customers.address', 'customers.phone', 'customers.membership', 'users.name as username')->firstOrFail();
     $list_item = TransactionItem::where('transaction_items.transaction_id', '=', $id)->join('items', 'transaction_items.item_id', '=', 'items.id')->select('transaction_items.*', 'transaction_items.id as trans_item_id', 'items.name as item_name')->get();
     $data = array('transaction' => $transaction, 'item_transaction' => $list_item);
     return $data;
 }
 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();
 }