1 | <?php |
||
21 | class CollectionEngine extends BaseEngine implements DataTableEngineContract |
||
22 | { |
||
23 | /** |
||
24 | * Collection object |
||
25 | * |
||
26 | * @var Collection |
||
27 | */ |
||
28 | public $collection; |
||
29 | |||
30 | /** |
||
31 | * Collection object |
||
32 | * |
||
33 | * @var Collection |
||
34 | */ |
||
35 | public $original_collection; |
||
36 | |||
37 | /** |
||
38 | * @param Collection $collection |
||
39 | * @param \Yajra\Datatables\Request $request |
||
40 | */ |
||
41 | public function __construct(Collection $collection, Request $request) |
||
|
|||
42 | { |
||
43 | $this->request = $request; |
||
44 | $this->collection = $collection; |
||
45 | $this->original_collection = $collection; |
||
46 | $this->columns = array_keys($this->serialize($collection->first())); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Serialize collection |
||
51 | * |
||
52 | * @param mixed $collection |
||
53 | * @return mixed|null |
||
54 | */ |
||
55 | protected function serialize($collection) |
||
59 | |||
60 | /** |
||
61 | * @inheritdoc |
||
62 | */ |
||
63 | public function filter(Closure $callback) |
||
64 | { |
||
65 | $this->overrideGlobalSearch($callback, $this); |
||
66 | |||
67 | return $this; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @inheritdoc |
||
72 | */ |
||
73 | public function showDebugger(array $output) |
||
74 | { |
||
75 | $output["input"] = $this->request->all(); |
||
76 | |||
77 | return $output; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @inheritdoc |
||
82 | */ |
||
83 | public function totalCount() |
||
87 | |||
88 | /** |
||
89 | * @inheritdoc |
||
90 | */ |
||
91 | public function count() |
||
95 | |||
96 | /** |
||
97 | * @inheritdoc |
||
98 | */ |
||
99 | public function ordering() |
||
122 | |||
123 | /** |
||
124 | * @inheritdoc |
||
125 | */ |
||
126 | public function filtering() |
||
153 | |||
154 | /** |
||
155 | * @inheritdoc |
||
156 | */ |
||
157 | public function columnSearch() |
||
180 | |||
181 | /** |
||
182 | * @inheritdoc |
||
183 | */ |
||
184 | public function paging() |
||
191 | |||
192 | /** |
||
193 | * @inheritdoc |
||
194 | */ |
||
195 | public function results() |
||
199 | |||
200 | /** |
||
201 | * @inheritdoc |
||
202 | */ |
||
203 | public function make($mDataSupport = false, $orderFirst = true) |
||
207 | } |
||
208 |