@@ -16,20 +16,20 @@ discard block |
||
16 | 16 | $this->users[] = $u; |
17 | 17 | } |
18 | 18 | |
19 | - public function getByEmail(string $email):?User |
|
19 | + public function getByEmail(string $email): ?User |
|
20 | 20 | { |
21 | - foreach ($this->users as $user){ |
|
22 | - if($user->email() === $email){ |
|
21 | + foreach ($this->users as $user) { |
|
22 | + if ($user->email() === $email) { |
|
23 | 23 | return $user; |
24 | 24 | } |
25 | 25 | } |
26 | 26 | return null; |
27 | 27 | } |
28 | 28 | |
29 | - public function getById(string $id):?User |
|
29 | + public function getById(string $id): ?User |
|
30 | 30 | { |
31 | - foreach ($this->users as $user){ |
|
32 | - if($user->id() === $id){ |
|
31 | + foreach ($this->users as $user) { |
|
32 | + if ($user->id() === $id) { |
|
33 | 33 | return $user; |
34 | 34 | } |
35 | 35 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | public function search(string $organizationId, int $page, int $perPage = 10): array |
40 | 40 | { |
41 | 41 | $users = []; |
42 | - foreach($this->users as $user){ |
|
43 | - if($user->organizationId() === $organizationId){ |
|
42 | + foreach ($this->users as $user) { |
|
43 | + if ($user->organizationId() === $organizationId) { |
|
44 | 44 | $users[] = $user->toDto(); |
45 | 45 | } |
46 | 46 | } |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | |
55 | 55 | public function update(User $u) |
56 | 56 | { |
57 | - foreach ($this->users as $key => $user){ |
|
58 | - if($user->id() === $u->id()){ |
|
57 | + foreach ($this->users as $key => $user) { |
|
58 | + if ($user->id() === $u->id()) { |
|
59 | 59 | $this->users[$key] = $u; |
60 | 60 | } |
61 | 61 | } |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | |
64 | 64 | public function delete(string $userId) |
65 | 65 | { |
66 | - foreach ($this->users as $key => $user){ |
|
67 | - if($user->id() === $userId){ |
|
66 | + foreach ($this->users as $key => $user) { |
|
67 | + if ($user->id() === $userId) { |
|
68 | 68 | unset($this->users[$key]); |
69 | 69 | } |
70 | 70 | } |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | public function getAdminOfOrganization(string $organizationId): array |
74 | 74 | { |
75 | 75 | $users = []; |
76 | - foreach ($this->users as $key => $user){ |
|
77 | - if($user->organizationId() === $organizationId && $user->isAdmin()){ |
|
76 | + foreach ($this->users as $key => $user) { |
|
77 | + if ($user->organizationId() === $organizationId && $user->isAdmin()) { |
|
78 | 78 | $users[] = $user; |
79 | 79 | } |
80 | 80 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | |
84 | 84 | public function getByProvider(string $provider, string $providerId): ?User |
85 | 85 | { |
86 | - foreach ($this->users as $user){ |
|
87 | - if($user->provider($provider, $providerId) === true){ |
|
86 | + foreach ($this->users as $user) { |
|
87 | + if ($user->provider($provider, $providerId) === true) { |
|
88 | 88 | return $user; |
89 | 89 | } |
90 | 90 | } |
@@ -9,5 +9,5 @@ |
||
9 | 9 | interface InvitationRepository |
10 | 10 | { |
11 | 11 | public function add(Invitation $i); |
12 | - public function getByHash(string $hash):?Invitation; |
|
12 | + public function getByHash(string $hash): ?Invitation; |
|
13 | 13 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | { |
30 | 30 | $invitations = []; |
31 | 31 | $organization = $this->organizationRepository->get($organizationId); |
32 | - foreach($users as $user){ |
|
32 | + foreach ($users as $user) { |
|
33 | 33 | $email = $user['email']; |
34 | 34 | $firstname = isset($user['firstname']) ? $user['firstname'] : ''; |
35 | 35 | $lastname = isset($user['lastname']) ? $user['lastname'] : ''; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function adminlte_image() |
30 | 30 | { |
31 | 31 | $urlPicture = $this->path_picture != "" ? asset('storage/'.str_replace('app/public/', '', $this->path_picture)) : null; |
32 | - if(!isset($urlPicture) || $urlPicture === ""){ |
|
32 | + if (!isset($urlPicture) || $urlPicture === "") { |
|
33 | 33 | $urlPicture = url('').'/'.config('adminlte.logo_img'); |
34 | 34 | } |
35 | 35 | return $urlPicture; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public function adminlte_desc() |
39 | 39 | { |
40 | 40 | $desc = ucfirst($this->firstname).' '.ucfirst($this->lastname); |
41 | - if($this->organization_id !== null){ |
|
41 | + if ($this->organization_id !== null) { |
|
42 | 42 | $organization = app(OrganizationRepository::class)->get($this->organization_id); |
43 | 43 | $desc .= ' - organisme : '.$organization->name(); |
44 | 44 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | public function getByEmail(string $email): ?User |
18 | 18 | { |
19 | 19 | $record = \App\User::where('email', $email)->first(); |
20 | - if(!isset($record)){ |
|
20 | + if (!isset($record)) { |
|
21 | 21 | return null; |
22 | 22 | } |
23 | 23 | $roles = $record->roles()->pluck('name')->toArray(); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function getById(string $id): ?User |
28 | 28 | { |
29 | 29 | $record = \App\User::where('uuid', $id)->first(); |
30 | - if(!isset($record)){ |
|
30 | + if (!isset($record)) { |
|
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | $roles = $record->roles()->pluck('name')->toArray(); |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | ->offset(($page-1)*$perPage) |
84 | 84 | ->limit($perPage) |
85 | 85 | ->get(); |
86 | - if(empty($records)){ |
|
86 | + if (empty($records)) { |
|
87 | 87 | return []; |
88 | 88 | } |
89 | 89 | |
90 | 90 | $users = []; |
91 | - foreach($records as $record){ |
|
92 | - if($record->uuid === null){ |
|
91 | + foreach ($records as $record) { |
|
92 | + if ($record->uuid === null) { |
|
93 | 93 | $identity = new Identity(Uuid::uuid4(), $record->iemail, $record->ifirstname, $record->ilastname, null); |
94 | 94 | $state = new State($organizationId, null, false, []); |
95 | 95 | $users[] = new UserDto($identity, $state); |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | public function getAdminOfOrganization(string $organizationId): array |
116 | 116 | { |
117 | 117 | $records = \App\User::role(['admin'])->where('organization_id', $organizationId)->get(); |
118 | - if(empty($records)){ |
|
118 | + if (empty($records)) { |
|
119 | 119 | return []; |
120 | 120 | } |
121 | 121 | $users = []; |
122 | - foreach($records as $record){ |
|
122 | + foreach ($records as $record) { |
|
123 | 123 | $roles = \App\User::find($record->id)->roles()->pluck('name')->toArray(); |
124 | 124 | $users[] = new User($record->uuid, $record->email, $record->firstname, $record->lastname, $record->organization_id, $record->path_picture, $roles); |
125 | 125 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function getByProvider(string $provider, string $providerId): ?User |
130 | 130 | { |
131 | 131 | $record = \App\User::where('providers->'.$provider, $providerId)->first(); |
132 | - if(!isset($record)){ |
|
132 | + if (!isset($record)) { |
|
133 | 133 | return null; |
134 | 134 | } |
135 | 135 | $roles = $record->roles()->pluck('name')->toArray(); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public function getStats(string $userId): Stats |
140 | 140 | { |
141 | 141 | $record = \App\User::where('uuid', $userId)->first(); |
142 | - if(isset($record) && $record->wiki_stats !== null){ |
|
142 | + if (isset($record) && $record->wiki_stats !== null) { |
|
143 | 143 | return new Stats($record->wiki_stats); |
144 | 144 | } |
145 | 145 | return new Stats([]); |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $socialiteUser = $this->socialiteGateway->user($provider); |
42 | 42 | |
43 | 43 | $user = $this->userRepository->getByProvider($provider, $socialiteUser->providerId()); |
44 | - if($user === null){ |
|
44 | + if ($user === null) { |
|
45 | 45 | throw ValidationException::withMessages([ |
46 | 46 | 'email' => [trans('auth.failed')], |
47 | 47 | ]); |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | public function __construct(array $data) |
22 | 22 | { |
23 | - foreach ($this->fields as $field){ |
|
23 | + foreach ($this->fields as $field) { |
|
24 | 24 | $this->stats[$field] = $this->dataOrZero($field, $data); |
25 | 25 | } |
26 | 26 | } |
@@ -14,12 +14,12 @@ |
||
14 | 14 | { |
15 | 15 | $token = $request->input('wiki_token', null); |
16 | 16 | |
17 | - if($token === null || $token === ''){ |
|
17 | + if ($token === null || $token === '') { |
|
18 | 18 | return ['error' => 'invalid_token']; |
19 | 19 | } |
20 | 20 | $user = User::where('wiki_token', $token)->first(); |
21 | 21 | |
22 | - if($user === null){ |
|
22 | + if ($user === null) { |
|
23 | 23 | return ['error' => 'invalid_token']; |
24 | 24 | } |
25 | 25 |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | |
29 | 29 | $this->dbWiki->table('user') |
30 | 30 | ->orderBy('user.user_id', 'desc') |
31 | - ->chunk(200, function ($records){ |
|
31 | + ->chunk(200, function($records) { |
|
32 | 32 | foreach ($records as $record) { |
33 | 33 | |
34 | 34 | $user = $this->userRepository->getByEmail($record->user_email); |
35 | - if(!isset($user)){ |
|
35 | + if (!isset($user)) { |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $editsOnWiki = $this->getEditsOnWikiNumber($record->user_id); |
43 | 43 | |
44 | 44 | |
45 | - $numberContributions = $questions + $answers + $votes + $editsOnWiki; |
|
45 | + $numberContributions = $questions+$answers+$votes+$editsOnWiki; |
|
46 | 46 | $fields = [ |
47 | 47 | 'number_contributions' => $numberContributions, |
48 | 48 | 'number_questions' => $questions, |