@@ -116,7 +116,9 @@ |
||
| 116 | 116 | $this->table = $table; |
| 117 | 117 | $this->prefix = $prefix; |
| 118 | 118 | |
| 119 | - if ( ! is_null($callback)) $callback($this); |
|
| 119 | + if ( ! is_null($callback)) { |
|
| 120 | + $callback($this); |
|
| 121 | + } |
|
| 120 | 122 | } |
| 121 | 123 | |
| 122 | 124 | /** |
@@ -121,7 +121,7 @@ |
||
| 121 | 121 | ? $this->wrapTable($segment) |
| 122 | 122 | : $this->wrapValue($segment); |
| 123 | 123 | } |
| 124 | - )->implode('.'); |
|
| 124 | + )->implode('.'); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -116,7 +116,7 @@ |
||
| 116 | 116 | */ |
| 117 | 117 | protected function wrapSegments($segments): string |
| 118 | 118 | { |
| 119 | - return collect($segments)->map(function ($segment, $key) use ($segments) { |
|
| 119 | + return collect($segments)->map(function($segment, $key) use ($segments) { |
|
| 120 | 120 | return $key == 0 && count($segments) > 1 |
| 121 | 121 | ? $this->wrapTable($segment) |
| 122 | 122 | : $this->wrapValue($segment); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function select(string $query, array $bindings = [], bool $useReadPdo = true): array |
| 270 | 270 | { |
| 271 | - return $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) { |
|
| 271 | + return $this->run($query, $bindings, function($query, $bindings) use ($useReadPdo) { |
|
| 272 | 272 | if ($this->pretending()) { |
| 273 | 273 | return []; |
| 274 | 274 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function statement(string $query, array $bindings = []): bool |
| 336 | 336 | { |
| 337 | - return $this->run($query, $bindings, function ($query, $bindings) { |
|
| 337 | + return $this->run($query, $bindings, function($query, $bindings) { |
|
| 338 | 338 | if ($this->pretending()) { |
| 339 | 339 | return true; |
| 340 | 340 | } |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | public function affectingStatement(string $query, array $bindings = []): int |
| 359 | 359 | { |
| 360 | - return $this->run($query, $bindings, function ($query, $bindings) { |
|
| 360 | + return $this->run($query, $bindings, function($query, $bindings) { |
|
| 361 | 361 | if ($this->pretending()) { |
| 362 | 362 | return 0; |
| 363 | 363 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | public function prepend(Closure $callback): array |
| 385 | 385 | { |
| 386 | - return $this->withFreshQueryLog(function () use ($callback) { |
|
| 386 | + return $this->withFreshQueryLog(function() use ($callback) { |
|
| 387 | 387 | $this->pretending = true; |
| 388 | 388 | |
| 389 | 389 | $callback($this); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * |
| 402 | 402 | * @return array|Closure |
| 403 | 403 | */ |
| 404 | - protected function withFreshQueryLog(Closure $callback): array|Closure |
|
| 404 | + protected function withFreshQueryLog(Closure $callback): array | Closure |
|
| 405 | 405 | { |
| 406 | 406 | $loggingQueries = $this->loggingQueries; |
| 407 | 407 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | { |
| 318 | 318 | $this->addSelect(new Expression($expression)); |
| 319 | 319 | |
| 320 | - if (! empty($bindings)) { |
|
| 320 | + if ( ! empty($bindings)) { |
|
| 321 | 321 | $this->addBinding($bindings, 'select'); |
| 322 | 322 | } |
| 323 | 323 | |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | protected function addArrayWheres($column, $boolean, $method = 'where'): static |
| 431 | 431 | { |
| 432 | - return $this->whereNested(function ($query) use ($column, $method, $boolean) { |
|
| 432 | + return $this->whereNested(function($query) use ($column, $method, $boolean) { |
|
| 433 | 433 | foreach ((array) $column as $key => $value) { |
| 434 | 434 | if (is_numeric($key) && is_array($value)) { |
| 435 | 435 | $query->{$method}(...array_values($value)); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | 'boolean' => $boolean |
| 567 | 567 | ]; |
| 568 | 568 | |
| 569 | - $this->addBinding((array) $bindings, 'where'); |
|
| 569 | + $this->addBinding((array) $bindings, 'where'); |
|
| 570 | 570 | |
| 571 | 571 | return $this; |
| 572 | 572 | } |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | */ |
| 1362 | 1362 | public function get($columns = ['*']) |
| 1363 | 1363 | { |
| 1364 | - return collect($this->getFresh(Arr::wrap($columns), function () { |
|
| 1364 | + return collect($this->getFresh(Arr::wrap($columns), function() { |
|
| 1365 | 1365 | return $this->getWithStatement(); |
| 1366 | 1366 | })); |
| 1367 | 1367 | } |
@@ -1491,7 +1491,7 @@ discard block |
||
| 1491 | 1491 | |
| 1492 | 1492 | $this->columns = $previous; |
| 1493 | 1493 | |
| 1494 | - if (isset($results[0])) { |
|
| 1494 | + if (isset($results[0])) { |
|
| 1495 | 1495 | $result = array_change_key_case((array) $results[0]); |
| 1496 | 1496 | } |
| 1497 | 1497 | |
@@ -63,13 +63,13 @@ |
||
| 63 | 63 | return $this->compileInsert($builder, $values).' returning '.$this->wrap($sequence); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Compile a truncate table statement into SQL. |
|
| 68 | - * |
|
| 69 | - * @param \Syscodes\Components\Database\Query\Builder $builder |
|
| 70 | - * |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 66 | + /** |
|
| 67 | + * Compile a truncate table statement into SQL. |
|
| 68 | + * |
|
| 69 | + * @param \Syscodes\Components\Database\Query\Builder $builder |
|
| 70 | + * |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | 73 | public function truncate(Builder $builder): array |
| 74 | 74 | { |
| 75 | 75 | return ['truncate table '.$this->wrapTable($builder->from).' restart identity cascade' => []]; |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | */ |
| 59 | 59 | public function compileInsertGetId(Builder $builder, $values, $sequence): string |
| 60 | 60 | { |
| 61 | - if (is_null($sequence)) $sequence = 'id' ; |
|
| 61 | + if (is_null($sequence)) $sequence = 'id'; |
|
| 62 | 62 | |
| 63 | 63 | return $this->compileInsert($builder, $values).' returning '.$this->wrap($sequence); |
| 64 | 64 | } |
@@ -58,7 +58,9 @@ |
||
| 58 | 58 | */ |
| 59 | 59 | public function compileInsertGetId(Builder $builder, $values, $sequence): string |
| 60 | 60 | { |
| 61 | - if (is_null($sequence)) $sequence = 'id' ; |
|
| 61 | + if (is_null($sequence)) { |
|
| 62 | + $sequence = 'id' ; |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | return $this->compileInsert($builder, $values).' returning '.$this->wrap($sequence); |
| 64 | 66 | } |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | $columns = $this->columnize(array_keys(headItem($values))); |
| 815 | 815 | |
| 816 | 816 | $parameters = collect($values)->map(fn ($record) => '('.$this->parameterize($record).')') |
| 817 | - ->implode(', '); |
|
| 817 | + ->implode(', '); |
|
| 818 | 818 | |
| 819 | 819 | return "insert into $table ($columns) values $parameters"; |
| 820 | 820 | } |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | */ |
| 918 | 918 | public function compileUpdateWithoutJoins(Builder $builder, $table, $columns, $where): string |
| 919 | 919 | { |
| 920 | - return "update {$table} set {$columns} {$where}"; |
|
| 920 | + return "update {$table} set {$columns} {$where}"; |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | */ |
| 971 | 971 | public function compileDeleteWithoutJoins(Builder $builder, $table, $where): string |
| 972 | 972 | { |
| 973 | - return "delete from {$table} {$where}"; |
|
| 973 | + return "delete from {$table} {$where}"; |
|
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $clauses = []; |
| 159 | 159 | |
| 160 | - foreach ($join->clauses as $clause) { |
|
| 160 | + foreach ($join->clauses as $clause) { |
|
| 161 | 161 | $clauses[] = $this->compileJoinContraint($clause); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function compileWheresToArray($query): array |
| 221 | 221 | { |
| 222 | - return collect($query->wheres)->map(function ($where) use ($query) { |
|
| 222 | + return collect($query->wheres)->map(function($where) use ($query) { |
|
| 223 | 223 | return $where['boolean'].' '.$this->{"where{$where['type']}"}($query, $where); |
| 224 | 224 | })->all(); |
| 225 | 225 | } |
@@ -340,7 +340,9 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | protected function whereIn(Builder $builder, $where): string |
| 342 | 342 | { |
| 343 | - if (empty($where['values'])) return '0 = 1'; |
|
| 343 | + if (empty($where['values'])) { |
|
| 344 | + return '0 = 1'; |
|
| 345 | + } |
|
| 344 | 346 | |
| 345 | 347 | return $this->wrap($where['column']).' in ('.$this->parameterize($where['values']).')'; |
| 346 | 348 | } |
@@ -355,7 +357,9 @@ discard block |
||
| 355 | 357 | */ |
| 356 | 358 | protected function whereNotIn(Builder $builder, $where): string |
| 357 | 359 | { |
| 358 | - if (empty($where['query'])) return '1 = 1'; |
|
| 360 | + if (empty($where['query'])) { |
|
| 361 | + return '1 = 1'; |
|
| 362 | + } |
|
| 359 | 363 | |
| 360 | 364 | $values = $this->parameterize($where['query']); |
| 361 | 365 | |
@@ -372,7 +376,9 @@ discard block |
||
| 372 | 376 | */ |
| 373 | 377 | protected function whereNotInRaw(Builder $builder, $where): string |
| 374 | 378 | { |
| 375 | - if (empty($where['values'])) return '1 = 1'; |
|
| 379 | + if (empty($where['values'])) { |
|
| 380 | + return '1 = 1'; |
|
| 381 | + } |
|
| 376 | 382 | |
| 377 | 383 | return $this->wrap($where['column']).' not in ('.implode(', ', $where['values']).')'; |
| 378 | 384 | } |
@@ -387,7 +393,9 @@ discard block |
||
| 387 | 393 | */ |
| 388 | 394 | protected function whereInRaw(Builder $builder, $where): string |
| 389 | 395 | { |
| 390 | - if (empty($where['values'])) return '0 = 1'; |
|
| 396 | + if (empty($where['values'])) { |
|
| 397 | + return '0 = 1'; |
|
| 398 | + } |
|
| 391 | 399 | |
| 392 | 400 | return $this->wrap($where['column']).' in ('.implode(', ', $where['values']).')'; |
| 393 | 401 | } |
@@ -181,13 +181,13 @@ |
||
| 181 | 181 | return 'select * from ('.$sql.') as '.$this->wrapTable('temp_table'); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * Compile a truncate table statement into SQL. |
|
| 186 | - * |
|
| 187 | - * @param \Syscodes\Components\Database\Query\Builder $builder |
|
| 188 | - * |
|
| 189 | - * @return array |
|
| 190 | - */ |
|
| 184 | + /** |
|
| 185 | + * Compile a truncate table statement into SQL. |
|
| 186 | + * |
|
| 187 | + * @param \Syscodes\Components\Database\Query\Builder $builder |
|
| 188 | + * |
|
| 189 | + * @return array |
|
| 190 | + */ |
|
| 191 | 191 | public function truncate(Builder $builder): array |
| 192 | 192 | { |
| 193 | 193 | return ['truncate table '.$this->wrapTable($builder->from) => []]; |
@@ -65,13 +65,13 @@ |
||
| 65 | 65 | return $connection; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Create a DSN string from a configuration. |
|
| 70 | - * |
|
| 71 | - * @param array $config |
|
| 72 | - * |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 68 | + /** |
|
| 69 | + * Create a DSN string from a configuration. |
|
| 70 | + * |
|
| 71 | + * @param array $config |
|
| 72 | + * |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | 75 | protected function getDsn(array $config): string |
| 76 | 76 | { |
| 77 | 77 | extract($config, EXTR_SKIP); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | return $instance; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - return take($this->newModelInstance(array_merge($attributes, $values)), function ($instance) { |
|
| 319 | + return take($this->newModelInstance(array_merge($attributes, $values)), function($instance) { |
|
| 320 | 320 | $instance->save(); |
| 321 | 321 | }); |
| 322 | 322 | } |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | */ |
| 467 | 467 | protected function getRelation($name) |
| 468 | 468 | { |
| 469 | - $relation = Relation::noConstraints(function () use ($name) { |
|
| 469 | + $relation = Relation::noConstraints(function() use ($name) { |
|
| 470 | 470 | try { |
| 471 | 471 | return $this->getModel()->newInstance()->$name(); |
| 472 | 472 | } catch (BadMethodCallException $e) { |