1 | <?php |
||
18 | class DisplayDatatablesAsync extends DisplayDatatables implements WithRoutesInterface |
||
19 | { |
||
20 | /** |
||
21 | * Register display routes. |
||
22 | * |
||
23 | * @param Router $router |
||
24 | */ |
||
25 | public static function registerRoutes(Router $router) |
||
68 | |||
69 | /** |
||
70 | * Find DisplayDatatablesAsync in tabbed display by name. |
||
71 | * |
||
72 | * @param DisplayTabbed $display |
||
73 | * @param string|null $name |
||
74 | * |
||
75 | * @return DisplayDatatablesAsync|null |
||
76 | */ |
||
77 | protected static function findDatatablesAsyncByName(DisplayTabbed $display, $name) |
||
87 | |||
88 | /** |
||
89 | * @var string |
||
90 | */ |
||
91 | protected $name; |
||
92 | |||
93 | /** |
||
94 | * @param string|null $name |
||
95 | */ |
||
96 | protected $distinct; |
||
97 | |||
98 | /** |
||
99 | * @var array |
||
100 | */ |
||
101 | protected $searchableColumns = [ |
||
102 | Text::class, |
||
103 | Link::class, |
||
104 | Email::class, |
||
105 | ]; |
||
106 | |||
107 | /** |
||
108 | * DisplayDatatablesAsync constructor. |
||
109 | * |
||
110 | * @param string|null $name |
||
111 | * @param string|null $distinct |
||
112 | */ |
||
113 | public function __construct($name = null, $distinct = null) |
||
122 | |||
123 | /** |
||
124 | * Initialize display. |
||
125 | */ |
||
126 | public function initialize() |
||
136 | |||
137 | /** |
||
138 | * @return string |
||
139 | */ |
||
140 | public function getName() |
||
144 | |||
145 | /** |
||
146 | * @param string $name |
||
147 | * |
||
148 | * @return $this |
||
149 | */ |
||
150 | public function setName($name) |
||
156 | |||
157 | /** |
||
158 | * @return mixed |
||
159 | */ |
||
160 | public function getDistinct() |
||
164 | |||
165 | /** |
||
166 | * @param mixed $distinct |
||
167 | * |
||
168 | * @return $this |
||
169 | */ |
||
170 | public function setDistinct($distinct) |
||
176 | |||
177 | /** |
||
178 | * Render async request. |
||
179 | * @return array |
||
180 | */ |
||
181 | public function renderAsync() |
||
205 | |||
206 | /** |
||
207 | * Apply offset and limit to the query. |
||
208 | * |
||
209 | * @param $query |
||
210 | */ |
||
211 | protected function applyOffset($query) |
||
222 | |||
223 | /** |
||
224 | * Apply search to the query. |
||
225 | * |
||
226 | * @param Builder $query |
||
227 | */ |
||
228 | protected function applySearch(Builder $query) |
||
247 | |||
248 | /** |
||
249 | * @param Builder $query |
||
250 | */ |
||
251 | protected function applyColumnSearch(Builder $query) |
||
266 | |||
267 | /** |
||
268 | * Convert collection to the datatables structure. |
||
269 | * |
||
270 | * @param array|Collection $collection |
||
271 | * @param int $totalCount |
||
272 | * @param int $filteredCount |
||
273 | * |
||
274 | * @return array |
||
275 | */ |
||
276 | protected function prepareDatatablesStructure(Collection $collection, $totalCount, $filteredCount) |
||
304 | } |
||
305 |
PHP has two types of connecting operators (logical operators, and boolean operators):
and
&&
or
||
The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&
, or||
.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
die
introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrow
at this point:These limitations lead to logical operators rarely being of use in current PHP code.