|
|
@@ -0,0 +1,48 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace App\Filters;
|
|
|
+
|
|
|
+use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
+
|
|
|
+class LaborCompanyDispatchFilters
|
|
|
+{
|
|
|
+ protected $request;
|
|
|
+ protected $queryBuilder;
|
|
|
+ protected $filters = [
|
|
|
+ 'dispatch_date_start',
|
|
|
+ 'dispatch_date_end',
|
|
|
+ ];
|
|
|
+
|
|
|
+ protected $orderIssueQuery;
|
|
|
+
|
|
|
+ public function __construct(Request $request)
|
|
|
+ {
|
|
|
+ $this->request = $request;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function apply($builder)
|
|
|
+ {
|
|
|
+ $this->queryBuilder = $builder;
|
|
|
+ $filters = array_filter($this->request->only($this->filters), function ($item) {
|
|
|
+ return $item !== null;
|
|
|
+ });
|
|
|
+ foreach ($filters as $filter => $value) {
|
|
|
+ if (method_exists($this, $filter)) {
|
|
|
+ $this->$filter($value, $this->queryBuilder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this->queryBuilder;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function dispatch_date_start($dispatch_date_start)
|
|
|
+ {
|
|
|
+ $this->queryBuilder->whereDate('dispatch_date', '>=', $dispatch_date_start);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function dispatch_date_end($dispatch_date_end)
|
|
|
+ {
|
|
|
+ $this->queryBuilder->whereDate('dispatch_date', '<=', $dispatch_date_end);
|
|
|
+ }
|
|
|
+}
|