@@ -23,10 +23,10 @@ |
||
23 | 23 | |
24 | 24 | print "update user"; |
25 | 25 | |
26 | -$name = ["Robson", "Kaue", "Gustavo", "João"]; |
|
26 | +$name = [ "Robson", "Kaue", "Gustavo", "João" ]; |
|
27 | 27 | |
28 | 28 | $user = (new User())->findById(100); |
29 | -$user->first_name = $name[rand(0, 3)]; |
|
29 | +$user->first_name = $name[ rand(0, 3) ]; |
|
30 | 30 | $user->save(); |
31 | 31 | |
32 | 32 | var_dump($user); |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | protected function update(array $data, string $terms, string $params): ?int |
38 | 38 | { |
39 | 39 | try { |
40 | - $dateSet = []; |
|
40 | + $dateSet = [ ]; |
|
41 | 41 | foreach ($data as $bind => $value) { |
42 | - $dateSet[] = "{$bind} = :{$bind}"; |
|
42 | + $dateSet[ ] = "{$bind} = :{$bind}"; |
|
43 | 43 | } |
44 | 44 | $dateSet = implode(", ", $dateSet); |
45 | 45 | parse_str($params, $params); |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | */ |
83 | 83 | private function filter(array $data): ?array |
84 | 84 | { |
85 | - $filter = []; |
|
85 | + $filter = [ ]; |
|
86 | 86 | foreach ($data as $key => $value) { |
87 | - $filter[$key] = (is_null($value) ? null : filter_var($value, FILTER_DEFAULT)); |
|
87 | + $filter[ $key ] = (is_null($value) ? null : filter_var($value, FILTER_DEFAULT)); |
|
88 | 88 | } |
89 | 89 | return $filter; |
90 | 90 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | protected $data; |
46 | 46 | |
47 | 47 | /** @var array $relational_fields no update or create */ |
48 | - protected $relational_fields = []; |
|
48 | + protected $relational_fields = [ ]; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * DataLayer constructor. |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | */ |
255 | 255 | protected function required(): bool |
256 | 256 | { |
257 | - $data = (array)$this->data(); |
|
257 | + $data = (array) $this->data(); |
|
258 | 258 | foreach ($this->required as $field) { |
259 | - if (empty($data[$field])) { |
|
259 | + if (empty($data[ $field ])) { |
|
260 | 260 | return false; |
261 | 261 | } |
262 | 262 | } |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | */ |
269 | 269 | protected function safe(): ?array |
270 | 270 | { |
271 | - $safe = (array)$this->data; |
|
272 | - foreach (array_merge([$this->primary, "updated_at", "created_at"], $this->relational_fields) as $unset) { |
|
273 | - unset($safe[$unset]); |
|
271 | + $safe = (array) $this->data; |
|
272 | + foreach (array_merge([ $this->primary, "updated_at", "created_at" ], $this->relational_fields) as $unset) { |
|
273 | + unset($safe[ $unset ]); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | return $safe; |
@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public function __construct() |
17 | 17 | { |
18 | - parent::__construct("socials", ["social", "link"]); |
|
18 | + parent::__construct("socials", [ "social", "link" ]); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public function __construct() |
17 | 17 | { |
18 | - parent::__construct("address", [], 'address_id'); |
|
18 | + parent::__construct("address", [ ], 'address_id'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function __construct() |
17 | 17 | { |
18 | - parent::__construct("users", ["first_name", "last_name"]); |
|
18 | + parent::__construct("users", [ "first_name", "last_name" ]); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function address(bool $obj = false): User |
26 | 26 | { |
27 | - $this->relational_fields[] = 'address'; |
|
27 | + $this->relational_fields[ ] = 'address'; |
|
28 | 28 | |
29 | 29 | if ($obj) { |
30 | 30 | $this->address = (new Address())->findByUser($this->id); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function socials(bool $obj = false): User |
48 | 48 | { |
49 | - $this->relational_fields[] = 'socials'; |
|
49 | + $this->relational_fields[ ] = 'socials'; |
|
50 | 50 | $socials = (new Socials())->getUserSocials($this->id); |
51 | 51 | |
52 | 52 | if ($obj) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | foreach ($socials as $key => $value) { |
63 | - $user_socials[] = $value->data(); |
|
63 | + $user_socials[ ] = $value->data(); |
|
64 | 64 | } |
65 | 65 | $this->socials = $user_socials; |
66 | 66 | return $this; |