@@ -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 = 'http://dev.core.tripleperformance.com:8008/vendor/adminlte/dist/img/AdminLTELogo.png'; |
| 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 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | public function register() |
| 28 | 28 | { |
| 29 | - if(config('app.env') === 'testing'){ |
|
| 29 | + if (config('app.env') === 'testing') { |
|
| 30 | 30 | $this->app->singleton(OrganizationRepository::class, InMemoryOrganizationRepository::class); |
| 31 | 31 | $this->app->singleton(PictureHandler::class, InMemoryPictureHandler::class); |
| 32 | 32 | $this->app->singleton(UserRepository::class, InMemoryUserRepository::class); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $this->app->singleton(AuthGateway::class, InMemoryAuthGateway::class); |
| 35 | 35 | $this->app->singleton(SocialiteGateway::class, InMemorySocialiteGateway::class); |
| 36 | 36 | } |
| 37 | - if(config('app.env') === 'testing-ti'){ |
|
| 37 | + if (config('app.env') === 'testing-ti') { |
|
| 38 | 38 | $this->app->singleton(OrganizationRepository::class, SqlOrganizationRepository::class); |
| 39 | 39 | $this->app->singleton(PictureHandler::class, InMemoryPictureHandler::class); |
| 40 | 40 | $this->app->singleton(UserRepository::class, InMemoryUserRepository::class); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $this->app->singleton(FileStorage::class, InMemoryFileStorage::class); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(config('app.env') === 'local'){ |
|
| 45 | + if (config('app.env') === 'local') { |
|
| 46 | 46 | $this->app->singleton(OrganizationRepository::class, SqlOrganizationRepository::class); |
| 47 | 47 | $this->app->singleton(PictureHandler::class, StoragePictureHandler::class); |
| 48 | 48 | $this->app->singleton(UserRepository::class, UserRepositorySql::class); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | public function getByEmail(string $email): ?User |
| 13 | 13 | { |
| 14 | 14 | $record = \App\User::where('email', $email)->first(); |
| 15 | - if(!isset($record)){ |
|
| 15 | + if (!isset($record)) { |
|
| 16 | 16 | return null; |
| 17 | 17 | } |
| 18 | 18 | $roles = $record->roles()->pluck('name')->toArray(); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function getById(string $id): ?User |
| 23 | 23 | { |
| 24 | 24 | $record = \App\User::where('uuid', $id)->first(); |
| 25 | - if(!isset($record)){ |
|
| 25 | + if (!isset($record)) { |
|
| 26 | 26 | return null; |
| 27 | 27 | } |
| 28 | 28 | $roles = $record->roles()->pluck('name')->toArray(); |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | ->offset(($page-1)*$perPage) |
| 68 | 68 | ->limit($perPage) |
| 69 | 69 | ->get(); |
| 70 | - if(empty($records)){ |
|
| 70 | + if (empty($records)) { |
|
| 71 | 71 | return []; |
| 72 | 72 | } |
| 73 | 73 | $users = []; |
| 74 | - foreach($records as $record){ |
|
| 74 | + foreach ($records as $record) { |
|
| 75 | 75 | $roles = \App\User::find($record->id)->roles()->pluck('name')->toArray(); |
| 76 | 76 | $users[] = new User($record->uuid, $record->email, $record->firstname, $record->lastname, $record->organization_id, $record->path_picture, $roles); |
| 77 | 77 | } |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | public function getAdminOfOrganization(string $organizationId): array |
| 91 | 91 | { |
| 92 | 92 | $records = \App\User::role(['admin'])->where('organization_id', $organizationId)->get(); |
| 93 | - if(empty($records)){ |
|
| 93 | + if (empty($records)) { |
|
| 94 | 94 | return []; |
| 95 | 95 | } |
| 96 | 96 | $users = []; |
| 97 | - foreach($records as $record){ |
|
| 97 | + foreach ($records as $record) { |
|
| 98 | 98 | $roles = \App\User::find($record->id)->roles()->pluck('name')->toArray(); |
| 99 | 99 | $users[] = new User($record->uuid, $record->email, $record->firstname, $record->lastname, $record->organization_id, $record->path_picture, $roles); |
| 100 | 100 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | public function getByProvider(string $provider, string $providerId): ?User |
| 105 | 105 | { |
| 106 | 106 | $record = \App\User::where('providers->'.$provider, $providerId)->first(); |
| 107 | - if(!isset($record)){ |
|
| 107 | + if (!isset($record)) { |
|
| 108 | 108 | return null; |
| 109 | 109 | } |
| 110 | 110 | $roles = $record->roles()->pluck('name')->toArray(); |
@@ -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; |
| 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 | } |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | return ucfirst($this->firstname).' '.ucfirst($this->lastname); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function organizationId():?string |
|
| 60 | + public function organizationId(): ?string |
|
| 61 | 61 | { |
| 62 | 62 | return $this->organizationId; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public function provider(string $provider, string $providerId):bool |
| 66 | 66 | { |
| 67 | - if(isset($this->providers[$provider]) && $this->providers[$provider] == $providerId){ |
|
| 67 | + if (isset($this->providers[$provider]) && $this->providers[$provider] == $providerId) { |
|
| 68 | 68 | return true; |
| 69 | 69 | } |
| 70 | 70 | return false; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | public function create(string $passwordHashed = null, Picture $picture = null) |
| 79 | 79 | { |
| 80 | - if(isset($picture)) { |
|
| 81 | - $picture->resize('app/public/users/' . $this->id); |
|
| 80 | + if (isset($picture)) { |
|
| 81 | + $picture->resize('app/public/users/'.$this->id); |
|
| 82 | 82 | $this->pathPicture = $picture->relativePath(); |
| 83 | 83 | } |
| 84 | 84 | app(UserRepository::class)->add($this, $passwordHashed); |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | $this->email = $email; |
| 121 | 121 | $this->firstname = $firstname; |
| 122 | 122 | $this->lastname = $lastname; |
| 123 | - if($pathPicture !== "") { |
|
| 123 | + if ($pathPicture !== "") { |
|
| 124 | 124 | $picture = new Picture($pathPicture); |
| 125 | - $picture->resize('app/public/users/' . $this->id . '.' . $ext); |
|
| 126 | - $this->pathPicture = 'app/public/users/' . $this->id . '.' . $ext; |
|
| 125 | + $picture->resize('app/public/users/'.$this->id.'.'.$ext); |
|
| 126 | + $this->pathPicture = 'app/public/users/'.$this->id.'.'.$ext; |
|
| 127 | 127 | } |
| 128 | 128 | app(UserRepository::class)->update($this); |
| 129 | 129 | } |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | interface UserRepository |
| 10 | 10 | { |
| 11 | - public function getByEmail(string $email):? User; |
|
| 12 | - public function getById(string $id):?User; |
|
| 13 | - public function getByProvider(string $provider, string $providerId):?User; |
|
| 11 | + public function getByEmail(string $email): ? User; |
|
| 12 | + public function getById(string $id): ?User; |
|
| 13 | + public function getByProvider(string $provider, string $providerId): ?User; |
|
| 14 | 14 | public function search(string $organizationId, int $page, int $perPage = 10): array; |
| 15 | 15 | public function add(User $u, string $password = null); |
| 16 | 16 | public function update(User $u); |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | */ |
| 90 | 90 | private function checkProviderAllowed(?string $provider, ?string $providerId): void |
| 91 | 91 | { |
| 92 | - if($provider === null || $providerId === null){ |
|
| 92 | + if ($provider === null || $providerId === null) { |
|
| 93 | 93 | throw new ProviderMissing(); |
| 94 | 94 | } |
| 95 | 95 | if (!in_array($provider, $this->allowedProviders)) { |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | $user = $this->userRepository->getByEmail($email); |
| 22 | 22 | if (isset($user)) { |
| 23 | 23 | $errors['email'] = __('validation.unique', ['attribute' => 'email']); |
| 24 | - $validator->after(function () use ($validator, $errors) { |
|
| 24 | + $validator->after(function() use ($validator, $errors) { |
|
| 25 | 25 | foreach ($errors as $field => $error) { |
| 26 | 26 | $validator->errors()->add($field, $error); |
| 27 | 27 | } |
@@ -22,17 +22,17 @@ |
||
| 22 | 22 | { |
| 23 | 23 | $relativePath = $newPath; |
| 24 | 24 | $finalNewPath = storage_path().'/'.$newPath; |
| 25 | - if(isset($this->ext)){ |
|
| 25 | + if (isset($this->ext)) { |
|
| 26 | 26 | $finalNewPath = storage_path().'/'.$newPath.'.'.$this->ext; |
| 27 | 27 | $relativePath = $newPath.'.'.$this->ext; |
| 28 | 28 | } |
| 29 | - if(app(PictureHandler::class)->width($this->path) > 600) { |
|
| 29 | + if (app(PictureHandler::class)->width($this->path) > 600) { |
|
| 30 | 30 | app(PictureHandler::class)->widen($this->path, $finalNewPath, 600); |
| 31 | 31 | $this->relativePath = $relativePath; |
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(app(PictureHandler::class)->height($this->path) > 400) { |
|
| 35 | + if (app(PictureHandler::class)->height($this->path) > 400) { |
|
| 36 | 36 | app(PictureHandler::class)->heighten($this->path, $finalNewPath, 400); |
| 37 | 37 | $this->relativePath = $relativePath; |
| 38 | 38 | return; |