@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $errors = []; |
29 | 29 | $user = $this->userRepository->getByEmail($email); |
30 | - if(isset($user) && $user->id() !== $userId){ |
|
30 | + if (isset($user) && $user->id() !== $userId) { |
|
31 | 31 | $errors[] = ['validation.unique']; |
32 | 32 | } |
33 | 33 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'email' => $email |
61 | 61 | ], $rules); |
62 | 62 | |
63 | - $validator->after(function () use ($validator, $errors) { |
|
63 | + $validator->after(function() use ($validator, $errors) { |
|
64 | 64 | foreach ($errors as $field => $error) { |
65 | 65 | $validator->errors()->add($field, $error); |
66 | 66 | } |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | |
25 | 25 | public function showLoginForm(Request $request) |
26 | 26 | { |
27 | - if($request->session()->has('should_attach_to_organization')) { |
|
27 | + if ($request->session()->has('should_attach_to_organization')) { |
|
28 | 28 | session()->reflash(); |
29 | 29 | } |
30 | - if($request->has('wiki_callback')){ |
|
30 | + if ($request->has('wiki_callback')) { |
|
31 | 31 | session()->flash('wiki_callback', $request->input('wiki_callback')); |
32 | 32 | session()->flash('wiki_token', $request->input('wiki_token')); |
33 | 33 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function logout(Request $request) |
38 | 38 | { |
39 | - if($request->session()->has('should_attach_to_organization')) { |
|
39 | + if ($request->session()->has('should_attach_to_organization')) { |
|
40 | 40 | $shouldAttach = $request->session()->get('should_attach_to_organization'); |
41 | 41 | $shouldAttachToken = $request->session()->get('should_attach_to_organization_token'); |
42 | 42 | $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect'); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $request->session()->regenerateToken(); |
50 | 50 | |
51 | - if(isset($shouldAttach)){ |
|
51 | + if (isset($shouldAttach)) { |
|
52 | 52 | $request->session()->flash('should_attach_to_organization', $shouldAttach); |
53 | 53 | $request->session()->flash('should_attach_to_organization_token', $shouldAttachToken); |
54 | 54 | $request->session()->flash('should_attach_to_organization_redirect', $linkToRedirect); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | protected function loggedOut(Request $request) |
67 | 67 | { |
68 | 68 | $request->session()->reflash(); |
69 | - if($request->session()->has('should_attach_to_organization')){ |
|
69 | + if ($request->session()->has('should_attach_to_organization')) { |
|
70 | 70 | $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect'); |
71 | 71 | return $request->wantsJson() |
72 | 72 | ? new Response('', 204) |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | |
77 | 77 | protected function authenticated(Request $request, $user) |
78 | 78 | { |
79 | - if($user->context_id === null){ |
|
79 | + if ($user->context_id === null) { |
|
80 | 80 | return redirect()->route('wizard.profile'); |
81 | 81 | } |
82 | 82 | |
83 | - if($request->session()->has('wiki_callback')){ |
|
83 | + if ($request->session()->has('wiki_callback')) { |
|
84 | 84 | $user->wiki_token = $request->session()->get('wiki_token'); |
85 | 85 | $user->save(); |
86 | 86 | $callback = urldecode($request->session()->get('wiki_callback')); |
87 | 87 | return redirect($callback); |
88 | 88 | } |
89 | - if($request->session()->has('should_attach_to_organization') && $request->session()->get('should_attach_to_organization') !== null){ |
|
89 | + if ($request->session()->has('should_attach_to_organization') && $request->session()->get('should_attach_to_organization') !== null) { |
|
90 | 90 | $token = $request->session()->get('should_attach_to_organization_token'); |
91 | 91 | $link = route('organization.invite.show').'?&token='.$token; |
92 | 92 | return $request->wantsJson() |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | public function redirectToProvider(string $provider) |
100 | 100 | { |
101 | - if($provider === 'twitter'){ |
|
101 | + if ($provider === 'twitter') { |
|
102 | 102 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK_LOGIN')]); |
103 | 103 | return Socialite::driver($provider)->redirect(); |
104 | 104 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | */ |
17 | 17 | public function handle($request, Closure $next) |
18 | 18 | { |
19 | - if(session()->has('wiki_callback')){ |
|
19 | + if (session()->has('wiki_callback')) { |
|
20 | 20 | session()->keep(['wiki_callback', 'wiki_token']); |
21 | 21 | } |
22 | 22 | return $next($request); |
@@ -27,12 +27,12 @@ |
||
27 | 27 | $w = $img->width(); |
28 | 28 | |
29 | 29 | $img = Image::cache(function($image) use($pathPicture, $dim, $w, $h){ |
30 | - if($w <= $h) { |
|
31 | - $image->make($pathPicture)->widen($dim, function ($constraint) { |
|
30 | + if ($w <= $h) { |
|
31 | + $image->make($pathPicture)->widen($dim, function($constraint) { |
|
32 | 32 | $constraint->upsize(); |
33 | 33 | }); |
34 | - }else{ |
|
35 | - $image->make($pathPicture)->heighten($dim, function ($constraint) { |
|
34 | + } else { |
|
35 | + $image->make($pathPicture)->heighten($dim, function($constraint) { |
|
36 | 36 | $constraint->upsize(); |
37 | 37 | }); |
38 | 38 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $image->make($pathPicture)->widen($dim, function ($constraint) { |
32 | 32 | $constraint->upsize(); |
33 | 33 | }); |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | $image->make($pathPicture)->heighten($dim, function ($constraint) { |
36 | 36 | $constraint->upsize(); |
37 | 37 | }); |
@@ -12,15 +12,15 @@ |
||
12 | 12 | { |
13 | 13 | public function user(string $provider): SocialiteUser |
14 | 14 | { |
15 | - if($provider === 'twitter'){ |
|
15 | + if ($provider === 'twitter') { |
|
16 | 16 | $user = Socialite::driver($provider)->user(); |
17 | - }else { |
|
17 | + } else { |
|
18 | 18 | $user = Socialite::driver($provider)->stateless()->user(); |
19 | 19 | } |
20 | 20 | |
21 | 21 | $email = $user->getEmail(); |
22 | 22 | $firstname = $user->getNickname() !== null ? $user->getNickname() : $user->getName(); |
23 | - if(isset($user->user['given_name'])){ |
|
23 | + if (isset($user->user['given_name'])) { |
|
24 | 24 | $firstname = $user->user['given_name']; |
25 | 25 | } |
26 | 26 | $lastname = isset($user->user['family_name']) ? $user->user['family_name'] : $user->getName(); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | if($provider === 'twitter'){ |
16 | 16 | $user = Socialite::driver($provider)->user(); |
17 | - }else { |
|
17 | + } else { |
|
18 | 18 | $user = Socialite::driver($provider)->stateless()->user(); |
19 | 19 | } |
20 | 20 |
@@ -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 | } |