@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - /*------------------------------------------------------------------------- |
|
4 | + /*------------------------------------------------------------------------- |
|
5 | 5 | | The application's global HTTP middleware stack. |
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | | |
8 | 8 | | These middleware are run during every request to your application. |
9 | 9 | */ |
10 | - 'global' => [], |
|
10 | + 'global' => [ ], |
|
11 | 11 | |
12 | 12 | /*------------------------------------------------------------------------- |
13 | 13 | | The application's middleware |
@@ -26,5 +26,5 @@ discard block |
||
26 | 26 | | Sometimes you may want to group several middleware under a |
27 | 27 | | single key to make them easier to assign to routes. |
28 | 28 | */ |
29 | - 'groups' => [] |
|
29 | + 'groups' => [ ] |
|
30 | 30 | ]; |
@@ -19,7 +19,7 @@ |
||
19 | 19 | { |
20 | 20 | public function handle() |
21 | 21 | { |
22 | - if (! Auth::check()) { |
|
22 | + if (!Auth::check()) { |
|
23 | 23 | header("Location: /login"); |
24 | 24 | exit(); |
25 | 25 | } |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @var array |
57 | 57 | */ |
58 | - protected $config = []; |
|
58 | + protected $config = [ ]; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * All of the queries run against the connection. |
62 | 62 | * |
63 | 63 | * @var array |
64 | 64 | */ |
65 | - protected $queryLog = []; |
|
65 | + protected $queryLog = [ ]; |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Indicates whether queries are being logged. |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected $loggingQueries = true; |
73 | 73 | |
74 | - public function __construct(Pdo $pdo, string $database = '', string $name = '', array $conf = []) |
|
74 | + public function __construct(Pdo $pdo, string $database = '', string $name = '', array $conf = [ ]) |
|
75 | 75 | { |
76 | 76 | $this->pdo = $pdo; |
77 | 77 | $this->name = $name; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function flushQueryLog() |
103 | 103 | { |
104 | - $this->queryLog = []; |
|
104 | + $this->queryLog = [ ]; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | |
162 | 162 | public function getDriver() |
163 | 163 | { |
164 | - return $this->config['driver']; |
|
164 | + return $this->config[ 'driver' ]; |
|
165 | 165 | } |
166 | 166 | |
167 | - public function select(string $query, array $bindings = [], $table = "") |
|
167 | + public function select(string $query, array $bindings = [ ], $table = "") |
|
168 | 168 | { |
169 | - return $this->run($query, $bindings, function ($me, $query, $bindings) use ($table) { |
|
169 | + return $this->run($query, $bindings, function($me, $query, $bindings) use ($table) { |
|
170 | 170 | // For select statements, we'll simply execute the query and return an array |
171 | 171 | // of the database result set. Each element in the array will be a single |
172 | 172 | // row from the database table, and will either be an array or objects. |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param array $bindings |
187 | 187 | * @return bool |
188 | 188 | */ |
189 | - public function insert($query, $bindings = []) |
|
189 | + public function insert($query, $bindings = [ ]) |
|
190 | 190 | { |
191 | 191 | return $this->statement($query, $bindings); |
192 | 192 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param array $bindings |
199 | 199 | * @return int |
200 | 200 | */ |
201 | - public function update($query, $bindings = []) |
|
201 | + public function update($query, $bindings = [ ]) |
|
202 | 202 | { |
203 | 203 | return $this->affectingStatement($query, $bindings); |
204 | 204 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param array $bindings |
211 | 211 | * @return int |
212 | 212 | */ |
213 | - public function delete($query, $bindings = []) |
|
213 | + public function delete($query, $bindings = [ ]) |
|
214 | 214 | { |
215 | 215 | return $this->affectingStatement($query, $bindings); |
216 | 216 | } |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | * @param array $bindings |
223 | 223 | * @return bool |
224 | 224 | */ |
225 | - public function statement($query, $bindings = []) |
|
225 | + public function statement($query, $bindings = [ ]) |
|
226 | 226 | { |
227 | - return $this->run($query, $bindings, function ($me, $query, $bindings) { |
|
227 | + return $this->run($query, $bindings, function($me, $query, $bindings) { |
|
228 | 228 | return $me->pdo->prepare($query)->execute($bindings); |
229 | 229 | }); |
230 | 230 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param array $bindings |
237 | 237 | * @return int |
238 | 238 | */ |
239 | - public function affectingStatement($query, $bindings = []) |
|
239 | + public function affectingStatement($query, $bindings = [ ]) |
|
240 | 240 | { |
241 | - return $this->run($query, $bindings, function ($me, $query, $bindings) { |
|
241 | + return $this->run($query, $bindings, function($me, $query, $bindings) { |
|
242 | 242 | |
243 | 243 | // For update or delete statements, we want to get the number of rows affected |
244 | 244 | // by the statement and return that back to the developer. We'll first need |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | { |
321 | 321 | $this->eventManager()->fire("ff.database.query_execution"); |
322 | 322 | |
323 | - if($this->loggingQueries) { |
|
324 | - $logEntry['startTime'] = $stopwatchEvent->getStartTime(); |
|
325 | - $logEntry['query'] = $query; |
|
326 | - $logEntry['bindings'] = $bindings; |
|
327 | - $logEntry['executionTime'] = $stopwatchEvent->getDuration(); |
|
323 | + if ($this->loggingQueries) { |
|
324 | + $logEntry[ 'startTime' ] = $stopwatchEvent->getStartTime(); |
|
325 | + $logEntry[ 'query' ] = $query; |
|
326 | + $logEntry[ 'bindings' ] = $bindings; |
|
327 | + $logEntry[ 'executionTime' ] = $stopwatchEvent->getDuration(); |
|
328 | 328 | |
329 | - $this->queryLog[] = $logEntry; |
|
329 | + $this->queryLog[ ] = $logEntry; |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function fetch(PDOStatement $statement) |
341 | 341 | { |
342 | - $result = []; |
|
342 | + $result = [ ]; |
|
343 | 343 | $statement = $statement->fetchAll(PDO::FETCH_ASSOC); |
344 | 344 | |
345 | 345 | foreach ($statement as $key => $value) { |
346 | - $result[$key] = new Model($this); |
|
347 | - $result[$key]->fillData($value); |
|
346 | + $result[ $key ] = new Model($this); |
|
347 | + $result[ $key ]->fillData($value); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | return $result; |
@@ -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 | } |
@@ -148,7 +148,7 @@ |
||
148 | 148 | * @throws StringObjectException |
149 | 149 | */ |
150 | 150 | public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, |
151 | - $parentKey = null, $relatedKey = null, $relation = null) |
|
151 | + $parentKey = null, $relatedKey = null, $relation = null) |
|
152 | 152 | { |
153 | 153 | /** @var Model $related */ |
154 | 154 | $related = $this->instantiateRelated($related); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @var array |
32 | 32 | */ |
33 | - protected $relations = []; |
|
33 | + protected $relations = [ ]; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Define a one-to-one relation |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $instance = $this->instantiateRelated($related); |
48 | 48 | |
49 | 49 | $foreignKey = $foreignKey ?: $this->getForeignKey(); |
50 | - $localKey = $localKey ?: $this->getPrimaryKey(); |
|
50 | + $localKey = $localKey ?: $this->getPrimaryKey(); |
|
51 | 51 | |
52 | 52 | // create new HasOne instance and return |
53 | 53 | return $this->newHasOne($instance->newQuery(), $this, $foreignKey, $localKey); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $instance = $this->instantiateRelated($related); |
83 | 83 | |
84 | 84 | $foreignKey = $foreignKey ?: $this->getForeignKey(); |
85 | - $localKey = $localKey ?: $this->getPrimaryKey(); |
|
85 | + $localKey = $localKey ?: $this->getPrimaryKey(); |
|
86 | 86 | |
87 | 87 | return $this->newHasMany( |
88 | 88 | $instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $related = $this->instantiateRelated($related); |
118 | 118 | |
119 | 119 | $foreignKey = $foreignKey ?: $this->getForeignKey(); |
120 | - $ownerKey = $ownerKey ?: $this->getPrimaryKey(); |
|
120 | + $ownerKey = $ownerKey ?: $this->getPrimaryKey(); |
|
121 | 121 | |
122 | 122 | return $this->newBelongsTo($related->newQuery(), $this, $foreignKey, $ownerKey, $related); |
123 | 123 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | $builder = $this->from($this->model->getTable()); |
81 | 81 | |
82 | 82 | if (!is_array($id)) { |
83 | - $id = [$id]; |
|
83 | + $id = [ $id ]; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | foreach ($id as $item) { |
@@ -100,12 +100,12 @@ |
||
100 | 100 | } catch (Error | BadMethodCallException $e) { |
101 | 101 | $pattern = '~^Call to undefined method (?P<class>[^:]+)::(?P<method>[^\(]+)\(\)$~'; |
102 | 102 | |
103 | - if (! preg_match($pattern, $e->getMessage(), $matches)) { |
|
103 | + if (!preg_match($pattern, $e->getMessage(), $matches)) { |
|
104 | 104 | throw $e; |
105 | 105 | } |
106 | 106 | |
107 | - if ($matches['class'] != get_class($object) || |
|
108 | - $matches['method'] != $method) { |
|
107 | + if ($matches[ 'class' ] != get_class($object) || |
|
108 | + $matches[ 'method' ] != $method) { |
|
109 | 109 | throw $e; |
110 | 110 | } |
111 | 111 |
@@ -67,7 +67,7 @@ |
||
67 | 67 | return $this->parent->getAttribute($this->localKey); |
68 | 68 | } |
69 | 69 | |
70 | - public function get(array $columns = ['*']) |
|
70 | + public function get(array $columns = [ '*' ]) |
|
71 | 71 | { |
72 | 72 | return $this->query->get($columns); |
73 | 73 | } |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function resolveTableName($table) |
94 | 94 | { |
95 | - if (! Str($table)->contains('\\') || ! class_exists($table)) { |
|
95 | + if (!Str($table)->contains('\\') || !class_exists($table)) { |
|
96 | 96 | return $table; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $model = new $table; |
100 | 100 | |
101 | - if (! $model instanceof Model) { |
|
101 | + if (!$model instanceof Model) { |
|
102 | 102 | return $table; |
103 | 103 | } |
104 | 104 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - public function get(array $columns = ['*']) |
|
140 | + public function get(array $columns = [ '*' ]) |
|
141 | 141 | { |
142 | 142 | return parent::get($columns, true); |
143 | 143 | } |