table; $data['db_key'] = $this->primaryKey; $data['route'] = $route; $cGlobal = new Controller(); if ($request->startDate) { $startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00'; $endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00'; }else{ $startDate = date('Y-m-d').' 00:00:00'; $endDate = date('Y-m-d').' 24:00:00'; } $dtable = DB::table("orders") ->join("users", function($join){ $join->on("users.user_id", "=", "orders.user_id"); }) ->leftJoin("merchant", function($join){ $join->on("merchant.mid", "=", "users.mid"); }) ->leftJoin("outlet", function($join){ $join->on("outlet.outlet_id", "=", "orders.outlet_id"); }) ->join("reff_order_type", function($join){ $join->on("reff_order_type.order_type_id", "=", "orders.order_type_id"); }) ->join("reff_bill_type", function($join){ $join->on("reff_bill_type.bill_type_id", "=", "orders.bill_type_id"); }) ->join("reff_payment_status", function($join){ $join->on("reff_payment_status.payment_status_id", "=", "orders.payment_status_id"); }) ->select("orders.*", "reff_bill_type.*", "merchant_nm", "reff_payment_status.payment_status_nm", "users.user_nm", "orders.outlet_id", "reff_order_type.*") ->where("orders.crtdt", ">=", $startDate) ->where("orders.crtdt", "<=", $endDate) ->when(request('merchant_filter') != null, function ($query) use ($request) { if ($request->merchant_filter != 'all') { $query->where('users.mid', $request->merchant_filter); } }) ->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) { $query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota); }) ->get(); // LIST DATA TABLE $data['data_table'] = $dtable; // FORM FIELD FOR STORE $data['set_field'] = [ ]; foreach($data['tableHead'] as $v){ $arrHead[] = $v[2]; } $data['head'] = implode(",",$arrHead); return $data; } public function getDT($data,$init) { $dt = DT::of($data); $dt->editColumn('crtdt',function($data) { return date('d-m-Y H:i:s',strtotime($data->crtdt)); }); $dt->editColumn('paydt',function($data) { return date('d-m-Y H:i:s',strtotime($data->paydt)); }); return $dt; } }