@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | return $this->firstname.' '.$this->lastname; |
62 | 62 | } |
63 | 63 | |
64 | - public function organizationId():?string |
|
64 | + public function organizationId(): ?string |
|
65 | 65 | { |
66 | 66 | return $this->organizationId; |
67 | 67 | } |
68 | 68 | |
69 | 69 | public function provider(string $provider, string $providerId):bool |
70 | 70 | { |
71 | - if(isset($this->providers[$provider]) && $this->providers[$provider] == $providerId){ |
|
71 | + if (isset($this->providers[$provider]) && $this->providers[$provider] == $providerId) { |
|
72 | 72 | return true; |
73 | 73 | } |
74 | 74 | return false; |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | |
88 | 88 | public function create(string $passwordHashed = null, Picture $picture = null) |
89 | 89 | { |
90 | - if(isset($picture)) { |
|
91 | - $picture->resize('app/public/users/' . $this->id); |
|
90 | + if (isset($picture)) { |
|
91 | + $picture->resize('app/public/users/'.$this->id); |
|
92 | 92 | $this->pathPicture = $picture->relativePath(); |
93 | 93 | } |
94 | 94 | app(UserRepository::class)->add($this, $passwordHashed); |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | $this->email = $email; |
131 | 131 | $this->firstname = $firstname; |
132 | 132 | $this->lastname = $lastname; |
133 | - if($pathPicture !== "") { |
|
133 | + if ($pathPicture !== "") { |
|
134 | 134 | $picture = new Picture($pathPicture); |
135 | - $picture->resize('app/public/users/' . $this->id . '.' . $ext); |
|
136 | - $this->pathPicture = 'app/public/users/' . $this->id . '.' . $ext; |
|
135 | + $picture->resize('app/public/users/'.$this->id.'.'.$ext); |
|
136 | + $this->pathPicture = 'app/public/users/'.$this->id.'.'.$ext; |
|
137 | 137 | } |
138 | 138 | app(UserRepository::class)->update($this); |
139 | 139 | } |
140 | 140 | |
141 | 141 | public function updateAvatar(string $pathPicture, string $ext = 'jpg') |
142 | 142 | { |
143 | - if($pathPicture !== "") { |
|
143 | + if ($pathPicture !== "") { |
|
144 | 144 | $picture = new Picture($pathPicture); |
145 | - $picture->resize('app/public/users/' . $this->id . '.' . $ext); |
|
146 | - $this->pathPicture = 'app/public/users/' . $this->id . '.' . $ext; |
|
145 | + $picture->resize('app/public/users/'.$this->id.'.'.$ext); |
|
146 | + $this->pathPicture = 'app/public/users/'.$this->id.'.'.$ext; |
|
147 | 147 | } |
148 | 148 | app(UserRepository::class)->update($this); |
149 | 149 | return $this->pathPicture; |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | |
16 | 16 | class ContextRepositorySql implements ContextRepository |
17 | 17 | { |
18 | - public function getByUser(string $userId):?Context |
|
18 | + public function getByUser(string $userId): ?Context |
|
19 | 19 | { |
20 | 20 | $user = User::where('uuid', $userId)->first(); |
21 | 21 | $context = DB::table('contexts')->where('id', $user->context_id)->first(); |
22 | - if($context == null){ |
|
22 | + if ($context == null) { |
|
23 | 23 | return null; |
24 | 24 | } |
25 | 25 | return new Context( |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | $user = User::where('uuid', $userId)->first(); |
39 | 39 | |
40 | 40 | $farmings = $contextData->get('farmings'); |
41 | - foreach($farmings as $farming){ |
|
42 | - $characteristic = CharacteristicsModel::where('uuid', (string)$farming)->first(); |
|
41 | + foreach ($farmings as $farming) { |
|
42 | + $characteristic = CharacteristicsModel::where('uuid', (string) $farming)->first(); |
|
43 | 43 | $user->characteristics()->save($characteristic); |
44 | 44 | } |
45 | 45 | |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | public function getByUserDto(string $userId): ?ContextDto |
53 | 53 | { |
54 | 54 | $user = User::where('uuid', $userId)->first(); |
55 | - if($user == null){ |
|
55 | + if ($user == null) { |
|
56 | 56 | return null; |
57 | 57 | } |
58 | 58 | $context = ContextModel::find($user->context_id); |
59 | - if($context == null){ |
|
59 | + if ($context == null) { |
|
60 | 60 | return null; |
61 | 61 | } |
62 | - $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item){ |
|
62 | + $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item) { |
|
63 | 63 | return $item->toDto(); |
64 | 64 | }); |
65 | 65 | |
66 | 66 | $numberDepartment = (new PostalCode($context->postal_code))->department(); |
67 | 67 | $characteristicDepartment = CharacteristicsModel::query()->where('code', $numberDepartment)->first(); |
68 | 68 | |
69 | - if(isset($characteristicDepartment)){ |
|
69 | + if (isset($characteristicDepartment)) { |
|
70 | 70 | $characteristics->push($characteristicDepartment->toDto()); |
71 | 71 | } |
72 | 72 | |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | public function update(Context $context, string $userId) |
85 | 85 | { |
86 | 86 | $user = User::where('uuid', $userId)->first(); |
87 | - if($user === null){ |
|
87 | + if ($user === null) { |
|
88 | 88 | return null; |
89 | 89 | } |
90 | 90 | |
91 | 91 | $contextModel = ContextModel::where('uuid', $context->id())->first(); |
92 | - if($contextModel === null){ |
|
92 | + if ($contextModel === null) { |
|
93 | 93 | return null; |
94 | 94 | } |
95 | 95 | $contextData = collect($context->toArray()); |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | |
98 | 98 | $farmings = $contextData->get('farmings'); |
99 | 99 | $characteristics = []; |
100 | - foreach($farmings as $farming){ |
|
101 | - $characteristicModel = CharacteristicsModel::where('uuid', (string)$farming)->first(); |
|
102 | - if(isset($characteristicModel)) { |
|
100 | + foreach ($farmings as $farming) { |
|
101 | + $characteristicModel = CharacteristicsModel::where('uuid', (string) $farming)->first(); |
|
102 | + if (isset($characteristicModel)) { |
|
103 | 103 | $characteristics[] = $characteristicModel->id; |
104 | 104 | } |
105 | 105 | } |
@@ -9,8 +9,8 @@ |
||
9 | 9 | |
10 | 10 | interface ContextRepository |
11 | 11 | { |
12 | - public function getByUser(string $userId):?Context; |
|
12 | + public function getByUser(string $userId): ?Context; |
|
13 | 13 | public function add(Context $context, string $userId); |
14 | 14 | public function update(Context $context, string $userId); |
15 | - public function getByUserDto(string $userId):?ContextDto; |
|
15 | + public function getByUserDto(string $userId): ?ContextDto; |
|
16 | 16 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $content = json_decode($response->getBody()->getContents(), true); |
24 | 24 | |
25 | 25 | $features = $content['features']; |
26 | - if(isset($features) && !empty($features)){ |
|
26 | + if (isset($features) && !empty($features)) { |
|
27 | 27 | $feature = $features[0]; |
28 | 28 | $coordinates = $feature['geometry']['coordinates']; |
29 | 29 | $departmentNumber = explode(',', $feature['properties']['context'])[0]; |