Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $totalScanSpg = ScanLog::where('agent_code', $agent->code)
- ->whereRaw("LOWER(activity_description) = 'spg'")->distinct('qrcode_code');
- if ($request->karesidenan || $request->dealer_code)
- $totalScanSpg->whereIn('branch_code', $locationDealerCode);
- $totalScanSpgPeriod = clone $totalScanSpg;
- if ($request->start_date)
- {
- $request_start_date = preg_match("/\\s/", $request->start_date) ? date('Y-m-d H:i:s', strtotime($request->start_date)) : date('Y-m-d 00:00:00', strtotime($request->start_date));
- $totalScanSpgPeriod->where(\DB::raw('IF(saved_at IS NOT NULL, saved_at, created_at)'), '>=', $request_start_date);
- }
- if ($request->end_date)
- {
- $request_end_date = preg_match("/\\s/", $request->end_date) ? date('Y-m-d H:i:s', strtotime($request->end_date)) : date('Y-m-d 23:59:59', strtotime($request->end_date));
- $totalScanSpgPeriod->where(\DB::raw('IF(saved_at IS NOT NULL, saved_at, created_at)'), '<=', $request_end_date);
- }
- $totalScanSpgPeriod = $totalScanSpgPeriod->count('qrcode_code');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement