@@ -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,19 +31,19 @@ discard block |
||
31 | 31 | { |
32 | 32 | $email = $firstname = $lastname = ''; |
33 | 33 | |
34 | - if($request->session()->has('user_to_register')){ |
|
34 | + if ($request->session()->has('user_to_register')) { |
|
35 | 35 | $user = $request->session()->get('user_to_register'); |
36 | 36 | $email = $user['email']; |
37 | 37 | $firstname = $user['firstname']; |
38 | 38 | $lastname = $user['lastname']; |
39 | 39 | } |
40 | 40 | |
41 | - if($request->has('wiki_callback')){ |
|
41 | + if ($request->has('wiki_callback')) { |
|
42 | 42 | session()->flash('wiki_callback', $request->input('wiki_callback')); |
43 | 43 | session()->flash('wiki_token', $request->input('wiki_token')); |
44 | 44 | } |
45 | 45 | |
46 | - if(session()->has('should_attach_to_organization')) { |
|
46 | + if (session()->has('should_attach_to_organization')) { |
|
47 | 47 | session()->reflash(); |
48 | 48 | } |
49 | 49 | return view('public.auth.register', [ |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | protected function validator(array $data) |
57 | 57 | { |
58 | - if(session()->has('should_attach_to_organization')) { |
|
58 | + if (session()->has('should_attach_to_organization')) { |
|
59 | 59 | session()->reflash(); |
60 | 60 | } |
61 | 61 | return Validator::make($data, [ |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | |
80 | 80 | protected function registered(Request $request, $user) |
81 | 81 | { |
82 | - if($request->session()->has('should_attach_to_organization')){ |
|
82 | + if ($request->session()->has('should_attach_to_organization')) { |
|
83 | 83 | app(AttachUserToAnOrganization::class)->attach($user->uuid, $request->session()->get('should_attach_to_organization')); |
84 | 84 | } |
85 | 85 | $user = Auth::user(); |
86 | 86 | |
87 | - if($user->context_id === null) { |
|
87 | + if ($user->context_id === null) { |
|
88 | 88 | return redirect()->route('wizard.profile'); |
89 | 89 | } |
90 | 90 | |
91 | - if($request->session()->has('wiki_callback')){ |
|
91 | + if ($request->session()->has('wiki_callback')) { |
|
92 | 92 | $user->wiki_token = $request->session()->get('wiki_token'); |
93 | 93 | $user->save(); |
94 | 94 | $callback = urldecode($request->session()->get('wiki_callback')); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | public function redirectToProvider(string $provider) |
102 | 102 | { |
103 | 103 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK')]); |
104 | - if($provider === 'twitter'){ |
|
104 | + if ($provider === 'twitter') { |
|
105 | 105 | return Socialite::driver($provider)->redirect(); |
106 | 106 | } |
107 | 107 | return Socialite::driver($provider)->redirectUrl(config('services.'.$provider.'.redirect'))->redirect(); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $user = User::where('uuid', $userId)->first(); |
115 | 115 | $this->guard()->login($user); |
116 | 116 | |
117 | - if($user->context_id !== null){ |
|
117 | + if ($user->context_id !== null) { |
|
118 | 118 | $user->wiki_token = $request->session()->get('wiki_token'); |
119 | 119 | $user->save(); |
120 | 120 | $callback = urldecode($request->session()->get('wiki_callback')); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | return redirect()->route('wizard.profile'); |
125 | - }catch (ValidationException $e) { |
|
125 | + } catch (ValidationException $e) { |
|
126 | 126 | $attributes = $e->validator->attributes(); |
127 | 127 | $attributes['provider'] = $provider; |
128 | 128 | return redirect()->route('register-social-network') |
@@ -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(); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | public function current(): ?User |
13 | 13 | { |
14 | 14 | $userModel = Auth::user(); |
15 | - if(!isset($userModel)){ |
|
15 | + if (!isset($userModel)) { |
|
16 | 16 | return null; |
17 | 17 | } |
18 | 18 | return new User($userModel->uuid, $userModel->email, $userModel->firstname, $userModel->lastname, $userModel->organization_id); |
@@ -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 | } |