Exemplo n.º 1
0
 /**
  * Get the query object to be processed by dataTables.
  *
  * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection
  */
 public function query()
 {
     if (Auth::User()->can('peminjaman.approve')) {
         $query = Peminjaman::with('detailPeminjaman', 'lokasi', 'detailPeminjaman.subKelompok')->select('*');
     } else {
         $query = Peminjaman::with('detailPeminjaman', 'lokasi', 'detailPeminjaman.subKelompok')->where('id_lokasi', '=', Auth::User()->id_lokasi)->select('*');
     }
     return $this->applyScopes($query);
 }
Exemplo n.º 2
0
 public function getSubBarang($id_lokasi)
 {
     $data = [];
     $peminjamans = Peminjaman::with(['detailPeminjaman.subKelompok', 'detailPeminjaman' => function ($query) {
         $query->groupBy('id_sub');
     }])->where('id_lokasi', '=', $id_lokasi)->selectRaw(['sum(detailpeminjaman.jumlah as jum'])->get();
     foreach ($peminjamans as $peminjaman) {
         foreach ($peminjaman->detailPeminjaman as $detailpeminjaman) {
             // $detailpeminjaman;
         }
     }
     return $peminjamans;
 }
Exemplo n.º 3
0
 public function getlaporan(Request $request)
 {
     $tgl1 = $request->input('start');
     $tgl2 = $request->input('end');
     // $tabel='jual';
     $datas['datas'] = Peminjaman::with('lokasi', 'detailPeminjaman.subKelompok')->whereBetween('created_at', [$tgl1, $tgl2])->get();
     $datas['tgl1'] = $tgl1;
     $datas['tgl2'] = $tgl2;
     $pdf = PDF::loadView('penjualan.datalaporan', $datas);
     return $pdf->download('laporan.pdf');
 }