@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | |
15 | 15 | class ContextRepositorySql implements ContextRepository |
16 | 16 | { |
17 | - public function getByUser(string $userId):?Context |
|
17 | + public function getByUser(string $userId): ?Context |
|
18 | 18 | { |
19 | 19 | $user = User::where('uuid', $userId)->first(); |
20 | 20 | $context = DB::table('contexts')->where('id', $user->context_id)->first(); |
21 | - if($context == null){ |
|
21 | + if ($context == null) { |
|
22 | 22 | return null; |
23 | 23 | } |
24 | 24 | return new Context($context->uuid, $context->postal_code, $user->characteristics()->pluck('uuid')->toArray()); |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | $user = User::where('uuid', $userId)->first(); |
31 | 31 | |
32 | 32 | $farmings = $contextData->get('farmings'); |
33 | - foreach($farmings as $farming){ |
|
34 | - $characteristic = CharacteristicsModel::where('uuid', (string)$farming)->first(); |
|
33 | + foreach ($farmings as $farming) { |
|
34 | + $characteristic = CharacteristicsModel::where('uuid', (string) $farming)->first(); |
|
35 | 35 | $user->characteristics()->save($characteristic); |
36 | 36 | } |
37 | 37 | |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | public function getByUserDto(string $userId): ?ContextDto |
45 | 45 | { |
46 | 46 | $user = User::where('uuid', $userId)->first(); |
47 | - if($user == null){ |
|
47 | + if ($user == null) { |
|
48 | 48 | return null; |
49 | 49 | } |
50 | 50 | $context = ContextModel::find($user->context_id); |
51 | - if($context == null){ |
|
51 | + if ($context == null) { |
|
52 | 52 | return null; |
53 | 53 | } |
54 | - $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item){ |
|
54 | + $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item) { |
|
55 | 55 | return $item->toDto(); |
56 | 56 | }); |
57 | 57 | return new ContextDto($user->firstname, $user->lastname, $context->postal_code, $characteristics->toArray()); |
@@ -33,7 +33,7 @@ |
||
33 | 33 | public function toDto() |
34 | 34 | { |
35 | 35 | $icon = null; |
36 | - if(isset($this->icon)){ |
|
36 | + if (isset($this->icon)) { |
|
37 | 37 | $icon = route('api.icon.serve', ['id' => $this->uuid]); |
38 | 38 | } |
39 | 39 | return new CharacteristicDto( |
@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | public function add(array $cs) |
27 | 27 | { |
28 | - foreach ($cs as $c){ |
|
28 | + foreach ($cs as $c) { |
|
29 | 29 | $cModel = new CharacteristicsModel(); |
30 | 30 | $cModel->fill($c); |
31 | 31 | $cModel->save(); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | $this->contextRepository = $contextRepository; |
17 | 17 | } |
18 | 18 | |
19 | - public function execute(string $userId):?ContextDto |
|
19 | + public function execute(string $userId): ?ContextDto |
|
20 | 20 | { |
21 | 21 | return $this->contextRepository->getByUserDto($userId); |
22 | 22 | } |
@@ -18,17 +18,17 @@ |
||
18 | 18 | $h = $img->height(); |
19 | 19 | $w = $img->width(); |
20 | 20 | |
21 | - if($dim == null){ |
|
21 | + if ($dim == null) { |
|
22 | 22 | return $img->response(); |
23 | 23 | } |
24 | 24 | |
25 | 25 | $img = Image::cache(function($image) use($pathPicture, $dim, $w, $h){ |
26 | - if($w <= $h) { |
|
27 | - $image->make($pathPicture)->widen($dim, function ($constraint) { |
|
26 | + if ($w <= $h) { |
|
27 | + $image->make($pathPicture)->widen($dim, function($constraint) { |
|
28 | 28 | $constraint->upsize(); |
29 | 29 | }); |
30 | - }else{ |
|
31 | - $image->make($pathPicture)->heighten($dim, function ($constraint) { |
|
30 | + } else { |
|
31 | + $image->make($pathPicture)->heighten($dim, function($constraint) { |
|
32 | 32 | $constraint->upsize(); |
33 | 33 | }); |
34 | 34 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $this->postalCode = $postalCode; |
23 | 23 | $this->department = (new PostalCode($postalCode))->department(); |
24 | 24 | $this->characteristics = $characteristics; |
25 | - foreach($this->characteristics as $characteristic){ |
|
25 | + foreach ($this->characteristics as $characteristic) { |
|
26 | 26 | $this->characteristicsByType[$characteristic->type()][] = $characteristic; |
27 | 27 | } |
28 | 28 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | private $type; |
13 | 13 | private $icon; |
14 | 14 | |
15 | - public function __construct(string $uuid, string $label, string $type, ?string $icon, $prettyLabel) |
|
15 | + public function __construct(string $uuid, string $label, string $type, ?string $icon, $prettyLabel) |
|
16 | 16 | { |
17 | 17 | $this->uuid = $uuid; |
18 | 18 | $this->label = $label; |
@@ -15,9 +15,9 @@ |
||
15 | 15 | |
16 | 16 | public function department():string |
17 | 17 | { |
18 | - if(substr($this->postalCode, 0, 2) > 96){ |
|
19 | - return substr($this->postalCode, 0,3); |
|
18 | + if (substr($this->postalCode, 0, 2) > 96) { |
|
19 | + return substr($this->postalCode, 0, 3); |
|
20 | 20 | } |
21 | - return substr($this->postalCode, 0,2); |
|
21 | + return substr($this->postalCode, 0, 2); |
|
22 | 22 | } |
23 | 23 | } |
@@ -11,5 +11,5 @@ |
||
11 | 11 | { |
12 | 12 | public function getByUser(string $userId); |
13 | 13 | public function add(Context $exploitation, string $userId); |
14 | - public function getByUserDto(string $userId):?ContextDto; |
|
14 | + public function getByUserDto(string $userId): ?ContextDto; |
|
15 | 15 | } |