@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $original = $query->columns; |
55 | 55 | |
56 | 56 | if (is_null($query->columns)) { |
57 | - $query->columns = ['*']; |
|
57 | + $query->columns = [ '*' ]; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // To compile the query, we'll spin through each component of the query and |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | // basic routine regardless of an amount of records given to us to insert. |
96 | 96 | $table = $this->wrapTable($query->from); |
97 | 97 | |
98 | - if (! is_array(reset($values))) { |
|
99 | - $values = [$values]; |
|
98 | + if (!is_array(reset($values))) { |
|
99 | + $values = [ $values ]; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $columns = $this->columnize(array_keys(reset($values))); |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | // We need to build a list of parameter place-holders of values that are bound |
105 | 105 | // to the query. Each insert should have the exact same amount of parameter |
106 | 106 | // bindings so we will loop through the record and parameterize them all. |
107 | - $parameters = []; |
|
107 | + $parameters = [ ]; |
|
108 | 108 | |
109 | 109 | foreach ($values as $record) { |
110 | - $parameters[] = '('.$this->parameterize($record).')'; |
|
110 | + $parameters[ ] = '('.$this->parameterize($record).')'; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $parameters = implode(', ', $parameters); |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | // Each one of the columns in the update statements needs to be wrapped in the |
130 | 130 | // keyword identifiers, also a place-holder needs to be created for each of |
131 | 131 | // the values in the list of bindings so we can make the sets statements. |
132 | - $columns = []; |
|
132 | + $columns = [ ]; |
|
133 | 133 | |
134 | 134 | foreach ($values as $key => $value) { |
135 | - $columns[] = $this->wrap($key)." = ?"; |
|
135 | + $columns[ ] = $this->wrap($key)." = ?"; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | $columns = implode(', ', $columns); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function compileTruncate(Builder $query) |
170 | 170 | { |
171 | - return ['truncate '.$this->wrapTable($query->from) => []]; |
|
171 | + return [ 'truncate '.$this->wrapTable($query->from) => [ ] ]; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function compileComponents(Builder $query) |
181 | 181 | { |
182 | - $sql = []; |
|
182 | + $sql = [ ]; |
|
183 | 183 | |
184 | 184 | foreach ($this->selectComponents as $component) { |
185 | 185 | // To compile the query, we'll spin through each component of the query and |
186 | 186 | // see if that component exists. If it does we'll just call the compiler |
187 | 187 | // function for the component which is responsible for making the SQL. |
188 | 188 | if (!is_null($query->$component)) { |
189 | - $method = 'compile' . ucfirst($component); |
|
189 | + $method = 'compile'.ucfirst($component); |
|
190 | 190 | |
191 | - $sql[$component] = $this->$method($query, $query->$component); |
|
191 | + $sql[ $component ] = $this->$method($query, $query->$component); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | $select = $query->distinct ? 'select distinct ' : 'select '; |
215 | 215 | |
216 | - return $select . $this->columnize($columns); |
|
216 | + return $select.$this->columnize($columns); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | protected function compileFrom(Builder $query, $table) |
227 | 227 | { |
228 | - return 'from ' . $this->wrapTable($table); |
|
228 | + return 'from '.$this->wrapTable($table); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | protected function compileWheres(Builder $query) |
238 | 238 | { |
239 | - $sql = []; |
|
239 | + $sql = [ ]; |
|
240 | 240 | |
241 | 241 | if (is_null($query->wheres)) { |
242 | 242 | return ''; |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | // for actually creating the where clauses SQL. This helps keep the code nice |
247 | 247 | // and maintainable since each clause has a very small method that it uses. |
248 | 248 | foreach ($query->wheres as $where) { |
249 | - $method = "where{$where['type']}"; |
|
249 | + $method = "where{$where[ 'type' ]}"; |
|
250 | 250 | |
251 | - $sql[] = $where['boolean'].' '.$this->$method($query, $where); |
|
251 | + $sql[ ] = $where[ 'boolean' ].' '.$this->$method($query, $where); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | // If we actually have some where clauses, we will strip off the first boolean |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | protected function compileOrders(Builder $query, $orders) |
274 | 274 | { |
275 | - return 'order by '.implode(', ', $orders[0])." ".$orders[1]; |
|
275 | + return 'order by '.implode(', ', $orders[ 0 ])." ".$orders[ 1 ]; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | protected function compileAggregate(Builder $query, $aggregate) |
298 | 298 | { |
299 | - $column = $this->columnize($aggregate['columns']); |
|
299 | + $column = $this->columnize($aggregate[ 'columns' ]); |
|
300 | 300 | |
301 | 301 | // If the query has a "distinct" constraint and we're not asking for all columns |
302 | 302 | // we need to prepend "distinct" onto the column name so that the query takes |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $column = 'distinct '.$column; |
306 | 306 | } |
307 | 307 | |
308 | - return 'select '.$aggregate['function'].'('.$column.') as aggregate'; |
|
308 | + return 'select '.$aggregate[ 'function' ].'('.$column.') as aggregate'; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | protected function whereBasic(Builder $query, $where) |
338 | 338 | { |
339 | 339 | // $value = $this->parameter($where['value']); |
340 | - return $this->wrap($where['column']).' '.$where['operator'].' ?'; //.$value; |
|
340 | + return $this->wrap($where[ 'column' ]).' '.$where[ 'operator' ].' ?'; //.$value; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | */ |
350 | 350 | protected function whereBetween(Builder $query, $where) |
351 | 351 | { |
352 | - $between = $where['not'] ? 'not between' : 'between'; |
|
352 | + $between = $where[ 'not' ] ? 'not between' : 'between'; |
|
353 | 353 | |
354 | - return $this->wrap($where['column']).' '.$between.' ? and ?'; |
|
354 | + return $this->wrap($where[ 'column' ]).' '.$between.' ? and ?'; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | */ |
364 | 364 | protected function whereIn(Builder $query, $where) |
365 | 365 | { |
366 | - $in = $where['not'] ? 'not in' : 'in'; |
|
366 | + $in = $where[ 'not' ] ? 'not in' : 'in'; |
|
367 | 367 | |
368 | 368 | $values = " ("; |
369 | 369 | |
370 | 370 | $count = count($query->getBindings()); |
371 | 371 | for ($i = 1; $i <= $count; $i++) { |
372 | - $append = ($count > $i) ? "," : ""; |
|
373 | - $values .= "?" . $append; |
|
372 | + $append = ($count > $i) ? "," : ""; |
|
373 | + $values .= "?".$append; |
|
374 | 374 | } |
375 | 375 | $values .= ")"; |
376 | 376 | |
377 | - return $this->wrap($where['column']). ' '.$in.$values; |
|
377 | + return $this->wrap($where[ 'column' ]).' '.$in.$values; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | */ |
387 | 387 | protected function whereNull(Builder $query, $where) |
388 | 388 | { |
389 | - $null = $where['not'] ? 'is not null' : 'is null'; |
|
389 | + $null = $where[ 'not' ] ? 'is not null' : 'is null'; |
|
390 | 390 | |
391 | - return $this->wrap($where['column']). ' '.$null; |
|
391 | + return $this->wrap($where[ 'column' ]).' '.$null; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | */ |
401 | 401 | protected function whereDate(Builder $builder, $where) |
402 | 402 | { |
403 | - return $this->wrap($where['column']).$where['operator'].$where['value']; |
|
403 | + return $this->wrap($where[ 'column' ]).$where[ 'operator' ].$where[ 'value' ]; |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | */ |
413 | 413 | protected function whereYear(Builder $builder, $where) |
414 | 414 | { |
415 | - return "year(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
415 | + return "year(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | */ |
425 | 425 | protected function whereMonth(Builder $builder, $where) |
426 | 426 | { |
427 | - return "month(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
427 | + return "month(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | */ |
437 | 437 | protected function whereDay(Builder $builder, $where) |
438 | 438 | { |
439 | - return "day(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
439 | + return "day(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -447,8 +447,8 @@ discard block |
||
447 | 447 | */ |
448 | 448 | protected function concatenate($segments) |
449 | 449 | { |
450 | - return implode(' ', array_filter($segments, function ($value) { |
|
451 | - return (string)$value !== ''; |
|
450 | + return implode(' ', array_filter($segments, function($value) { |
|
451 | + return (string) $value !== ''; |
|
452 | 452 | })); |
453 | 453 | } |
454 | 454 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | */ |
461 | 461 | public function columnize(array $columns) |
462 | 462 | { |
463 | - return implode(', ', array_map([$this, 'wrap'], $columns)); |
|
463 | + return implode(', ', array_map([ $this, 'wrap' ], $columns)); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -471,10 +471,10 @@ discard block |
||
471 | 471 | */ |
472 | 472 | public function parameterize(array $values) |
473 | 473 | { |
474 | - $val = array_map([$this, 'parameter'], $values); |
|
474 | + $val = array_map([ $this, 'parameter' ], $values); |
|
475 | 475 | |
476 | 476 | foreach ($val as $key => $item) { |
477 | - $val[$key] = $this->quoteString($item); |
|
477 | + $val[ $key ] = $this->quoteString($item); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | return implode(', ', $val); |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | |
483 | 483 | public function parameterizeForUpdate(array $columns, array $values) |
484 | 484 | { |
485 | - $queryValues = []; |
|
485 | + $queryValues = [ ]; |
|
486 | 486 | |
487 | 487 | $count = count($values); |
488 | 488 | for ($i = 0; $i < $count; $i++) { |
489 | - $queryValues[] = $columns[$i]."=".$this->quoteString(array_values($values)[$i]); |
|
489 | + $queryValues[ ] = $columns[ $i ]."=".$this->quoteString(array_values($values)[ $i ]); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | return implode(", ", $queryValues); |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | public function quoteString($value) |
513 | 513 | { |
514 | 514 | if (is_array($value)) { |
515 | - return implode(', ', array_map([$this, __FUNCTION__], $value)); |
|
515 | + return implode(', ', array_map([ $this, __FUNCTION__ ], $value)); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | return "'$value'"; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | public function wrapTable($table) |
528 | 528 | { |
529 | 529 | if (!$this->isExpression($table)) { |
530 | - return $this->wrap($this->tablePrefix . $table, true); |
|
530 | + return $this->wrap($this->tablePrefix.$table, true); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | return $this->getValue($table); |
@@ -553,13 +553,13 @@ discard block |
||
553 | 553 | $segments = explode(' ', $value); |
554 | 554 | |
555 | 555 | if ($prefixAlias) { |
556 | - $segments[2] = $this->tablePrefix.$segments[2]; |
|
556 | + $segments[ 2 ] = $this->tablePrefix.$segments[ 2 ]; |
|
557 | 557 | } |
558 | 558 | |
559 | - return $this->wrap($segments[0]).' as '.$this->wrapValue($segments[2]); |
|
559 | + return $this->wrap($segments[ 0 ]).' as '.$this->wrapValue($segments[ 2 ]); |
|
560 | 560 | } |
561 | 561 | |
562 | - $wrapped = []; |
|
562 | + $wrapped = [ ]; |
|
563 | 563 | |
564 | 564 | $segments = explode('.', $value); |
565 | 565 | |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | // segments as if it was a table and the rest as just regular values. |
569 | 569 | foreach ($segments as $key => $segment) { |
570 | 570 | if ($key == 0 && count($segments) > 1) { |
571 | - $wrapped[] = $this->wrapTable($segment); |
|
571 | + $wrapped[ ] = $this->wrapTable($segment); |
|
572 | 572 | } else { |
573 | - $wrapped[] = $this->wrapValue($segment); |
|
573 | + $wrapped[ ] = $this->wrapValue($segment); |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
@@ -592,11 +592,11 @@ discard block |
||
592 | 592 | // as well in order to generate proper syntax. If this is a column of course |
593 | 593 | // no prefix is necessary. The condition will be true when from wrapTable. |
594 | 594 | if ($prefixAlias) { |
595 | - $segments[1] = $this->tablePrefix . $segments[1]; |
|
595 | + $segments[ 1 ] = $this->tablePrefix.$segments[ 1 ]; |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | return $this->wrap( |
599 | - $segments[0]) . ' as ' . $this->wrapValue($segments[1] |
|
599 | + $segments[ 0 ]).' as '.$this->wrapValue($segments[ 1 ] |
|
600 | 600 | ); |
601 | 601 | } |
602 | 602 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | */ |
609 | 609 | protected function wrapSegments($segments) |
610 | 610 | { |
611 | - return arr($segments)->map(function ($segment, $key) use ($segments) { |
|
611 | + return arr($segments)->map(function($segment, $key) use ($segments) { |
|
612 | 612 | return $key == 0 && count($segments) > 1 |
613 | 613 | ? $this->wrapTable($segment) |
614 | 614 | : $this->wrapValue($segment); |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | protected function wrapValue($value) |
625 | 625 | { |
626 | 626 | if ($value !== '*') { |
627 | - return '`' . str_replace('"', '""', $value) . '`'; |
|
627 | + return '`'.str_replace('"', '""', $value).'`'; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | return $value; |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @var array |
80 | 80 | */ |
81 | - protected $attributes = []; |
|
81 | + protected $attributes = [ ]; |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * The model attribute's original state. |
85 | 85 | * |
86 | 86 | * @var array |
87 | 87 | */ |
88 | - protected $original = []; |
|
88 | + protected $original = [ ]; |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * The number of models to return for pagination. |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * Model constructor. |
121 | 121 | * @param array $attributes |
122 | 122 | */ |
123 | - public function __construct(array $attributes = []) |
|
123 | + public function __construct(array $attributes = [ ]) |
|
124 | 124 | { |
125 | 125 | $this->bootIfNotBooted(); |
126 | 126 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function bootIfNotBooted() |
141 | 141 | { |
142 | - if (! self::$isBooted) { |
|
142 | + if (!self::$isBooted) { |
|
143 | 143 | self::boot(); |
144 | 144 | |
145 | 145 | self::$isBooted = true; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function syncOriginalAttribute($attribute) |
168 | 168 | { |
169 | - $this->original[$attribute] = $this->attributes[$attribute]; |
|
169 | + $this->original[ $attribute ] = $this->attributes[ $attribute ]; |
|
170 | 170 | |
171 | 171 | return $this; |
172 | 172 | } |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | * @param array $columns |
294 | 294 | * @return mixed |
295 | 295 | */ |
296 | - public static function all(array $columns = ['*']) |
|
296 | + public static function all(array $columns = [ '*' ]) |
|
297 | 297 | { |
298 | 298 | $instance = new static(); |
299 | 299 | /** @var ArrayObject $result */ |
300 | 300 | $result = $instance->newQuery()->get($columns); |
301 | 301 | |
302 | - $result->map(function ($item) { |
|
302 | + $result->map(function($item) { |
|
303 | 303 | $item->exists = true; |
304 | 304 | }); |
305 | 305 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $instance = new static(); |
316 | 316 | $result = $instance->newQuery()->find($id); |
317 | 317 | |
318 | - if (! is_null($result)) { |
|
318 | + if (!is_null($result)) { |
|
319 | 319 | $result->exists = true; |
320 | 320 | } |
321 | 321 | |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | { |
352 | 352 | $instance = new static(); |
353 | 353 | |
354 | - if (! is_array($id)) { |
|
355 | - $id = [$id]; |
|
354 | + if (!is_array($id)) { |
|
355 | + $id = [ $id ]; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | return $instance->newQuery()->remove($id); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function setAttribute($key, $value) |
384 | 384 | { |
385 | - $this->attributes[$key] = $value; |
|
385 | + $this->attributes[ $key ] = $value; |
|
386 | 386 | |
387 | 387 | return $this; |
388 | 388 | } |
@@ -400,11 +400,11 @@ discard block |
||
400 | 400 | */ |
401 | 401 | public function getAttribute($key) |
402 | 402 | { |
403 | - if (! $key) { |
|
403 | + if (!$key) { |
|
404 | 404 | return; |
405 | 405 | } |
406 | 406 | |
407 | - $attr = $this->getAttributes()[$key]; |
|
407 | + $attr = $this->getAttributes()[ $key ]; |
|
408 | 408 | |
409 | 409 | if (isset($attr)) { |
410 | 410 | return $attr; |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | */ |
577 | 577 | public function offsetExists($offset) |
578 | 578 | { |
579 | - return isset($this->attributes[$offset]); |
|
579 | + return isset($this->attributes[ $offset ]); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | */ |
591 | 591 | public function offsetGet($offset) |
592 | 592 | { |
593 | - return $this->attributes[$offset]; |
|
593 | + return $this->attributes[ $offset ]; |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | */ |
608 | 608 | public function offsetSet($offset, $value) |
609 | 609 | { |
610 | - $this->attributes[$offset] = $value; |
|
610 | + $this->attributes[ $offset ] = $value; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | */ |
622 | 622 | public function offsetUnset($offset) |
623 | 623 | { |
624 | - unset($this->attributes[$offset]); |
|
624 | + unset($this->attributes[ $offset ]); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | { |
690 | 690 | $time = $this->freshTimestamp(); |
691 | 691 | |
692 | - if (! is_null(static::UPDATED_AT) ) { |
|
692 | + if (!is_null(static::UPDATED_AT)) { |
|
693 | 693 | $this->setUpdatedAt($time); |
694 | 694 | } |
695 | 695 | |
696 | - if (! is_null(static::CREATED_AT)) { |
|
696 | + if (!is_null(static::CREATED_AT)) { |
|
697 | 697 | $this->setCreatedAt($time); |
698 | 698 | } |
699 | 699 | } |
@@ -749,12 +749,12 @@ discard block |
||
749 | 749 | */ |
750 | 750 | private function getDifference() |
751 | 751 | { |
752 | - $attributes = []; |
|
752 | + $attributes = [ ]; |
|
753 | 753 | foreach ($this->getAttributes() as $attKey => $attribute) { |
754 | 754 | foreach ($this->original as $oriKey => $original) { |
755 | 755 | if ($attKey == $oriKey) { |
756 | 756 | if ($attribute !== $original) { |
757 | - $attributes[$attKey] = $attribute; |
|
757 | + $attributes[ $attKey ] = $attribute; |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | } |