@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | ->select() |
| 18 | 18 | ->where('uuid', $id) |
| 19 | 19 | ->first(); |
| 20 | - if(!isset($record)){ |
|
| 20 | + if (!isset($record)) { |
|
| 21 | 21 | return null; |
| 22 | 22 | } |
| 23 | 23 | $address = new Address($record->city, $record->address1, $record->address2, $record->postal_code); |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | ->offset(($page-1)*$perPage) |
| 43 | 43 | ->limit($perPage) |
| 44 | 44 | ->get(); |
| 45 | - if(empty($records)){ |
|
| 45 | + if (empty($records)) { |
|
| 46 | 46 | return []; |
| 47 | 47 | } |
| 48 | 48 | $organizations = []; |
| 49 | - foreach($records as $record){ |
|
| 49 | + foreach ($records as $record) { |
|
| 50 | 50 | $address = new Address($record->city, $record->address1, $record->address2, $record->postal_code); |
| 51 | 51 | $organizations[] = new Organization($record->uuid, $record->name, $record->path_picture, $address); |
| 52 | 52 | } |
@@ -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 | } |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | $usersToProcess = []; |
| 24 | 24 | $usersLoop = $this->getUsersToProcess($users, $usersLoop, $filePathUsers); |
| 25 | 25 | $errors = $imported = 0; |
| 26 | - foreach($usersLoop as $userToInvite){ |
|
| 26 | + foreach ($usersLoop as $userToInvite) { |
|
| 27 | 27 | $rules = [ |
| 28 | 28 | 'email' => 'email|required|min:2|max:255', |
| 29 | 29 | 'firstname' => 'string|max:100', |
| 30 | 30 | 'lastname' => 'string|max:100', |
| 31 | 31 | ]; |
| 32 | 32 | $validator = Validator::make($userToInvite, $rules); |
| 33 | - if($validator->fails()){ |
|
| 33 | + if ($validator->fails()) { |
|
| 34 | 34 | $userToInvite['error'] = 'email.error.syntax'; |
| 35 | 35 | $usersToProcess['users'][] = $userToInvite; |
| 36 | 36 | $errors++; |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $user = $this->userRepository->getByEmail($userToInvite['email']); |
| 41 | - if(isset($user) && $user->organizationId() === $organizationId) { |
|
| 41 | + if (isset($user) && $user->organizationId() === $organizationId) { |
|
| 42 | 42 | $userToInvite["error"] = 'already_in'; |
| 43 | 43 | $errors++; |
| 44 | 44 | } |
| 45 | 45 | $usersToProcess['users'][] = $userToInvite; |
| 46 | 46 | |
| 47 | - if(!isset($userToInvite["error"])){ |
|
| 47 | + if (!isset($userToInvite["error"])) { |
|
| 48 | 48 | $imported++; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | public function invite(string $organizationId, array $users) |
| 21 | 21 | { |
| 22 | 22 | $organization = $this->organizationRepository->get($organizationId); |
| 23 | - foreach($users as $user){ |
|
| 23 | + foreach ($users as $user) { |
|
| 24 | 24 | $email = $user['email']; |
| 25 | 25 | $firstname = isset($user['firstname']) ? $user['firstname'] : ''; |
| 26 | 26 | $lastname = isset($user['lastname']) ? $user['lastname'] : ''; |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function create(string $ext = 'jpg') |
| 35 | 35 | { |
| 36 | - if($this->pathPicture !== "") { |
|
| 36 | + if ($this->pathPicture !== "") { |
|
| 37 | 37 | $picture = new Picture($this->pathPicture); |
| 38 | - $picture->resize('app/public/organizations/' . $this->id . '.' . $ext); |
|
| 39 | - $this->pathPicture = 'app/public/organizations/' . $this->id . '.' . $ext; |
|
| 38 | + $picture->resize('app/public/organizations/'.$this->id.'.'.$ext); |
|
| 39 | + $this->pathPicture = 'app/public/organizations/'.$this->id.'.'.$ext; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | app(OrganizationRepository::class)->add($this); |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $this->name = $name; |
| 48 | 48 | $this->address = $address; |
| 49 | - if($picture['path'] !== "") { |
|
| 49 | + if ($picture['path'] !== "") { |
|
| 50 | 50 | $logo = new Picture($picture['path']); |
| 51 | 51 | $ext = $picture['ext']; |
| 52 | - $logo->resize('app/public/organizations/' . $this->id . '.' . $ext); |
|
| 53 | - $this->pathPicture = 'app/public/organizations/' . $this->id . '.' . $ext; |
|
| 52 | + $logo->resize('app/public/organizations/'.$this->id.'.'.$ext); |
|
| 53 | + $this->pathPicture = 'app/public/organizations/'.$this->id.'.'.$ext; |
|
| 54 | 54 | } |
| 55 | 55 | app(OrganizationRepository::class)->update($this); |
| 56 | 56 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | interface OrganizationRepository |
| 10 | 10 | { |
| 11 | - public function get(string $id):? Organization; |
|
| 11 | + public function get(string $id): ? Organization; |
|
| 12 | 12 | public function add(Organization $o); |
| 13 | 13 | public function update(Organization $o); |
| 14 | 14 | public function search(int $page, int $perPage = 10): array; |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | |
| 9 | 9 | interface UserRepository |
| 10 | 10 | { |
| 11 | - public function getByEmail(string $email):? User; |
|
| 12 | - public function getById(string $id):?User; |
|
| 11 | + public function getByEmail(string $email): ? User; |
|
| 12 | + public function getById(string $id): ?User; |
|
| 13 | 13 | public function search(string $organizationId, int $page, int $perPage = 10): array; |
| 14 | 14 | public function add(User $u, string $password = null); |
| 15 | 15 | public function update(User $u); |
@@ -17,12 +17,12 @@ |
||
| 17 | 17 | |
| 18 | 18 | public function resize(string $newPath) |
| 19 | 19 | { |
| 20 | - if(app(PictureHandler::class)->width($this->path) > 600) { |
|
| 20 | + if (app(PictureHandler::class)->width($this->path) > 600) { |
|
| 21 | 21 | app(PictureHandler::class)->widen($this->path, storage_path().'/'.$newPath, 600); |
| 22 | 22 | return; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if(app(PictureHandler::class)->height($this->path) > 400) { |
|
| 25 | + if (app(PictureHandler::class)->height($this->path) > 400) { |
|
| 26 | 26 | app(PictureHandler::class)->heighten($this->path, storage_path().'/'.$newPath, 400); |
| 27 | 27 | return; |
| 28 | 28 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | return $this->id; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function organizationId():?string |
|
| 42 | + public function organizationId(): ?string |
|
| 43 | 43 | { |
| 44 | 44 | return $this->organizationId; |
| 45 | 45 | } |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | $this->email = $email; |
| 79 | 79 | $this->firstname = $firstname; |
| 80 | 80 | $this->lastname = $lastname; |
| 81 | - if($pathPicture !== "") { |
|
| 81 | + if ($pathPicture !== "") { |
|
| 82 | 82 | $picture = new Picture($pathPicture); |
| 83 | - $picture->resize('app/public/users/' . $this->id . '.' . $ext); |
|
| 84 | - $this->pathPicture = 'app/public/users/' . $this->id . '.' . $ext; |
|
| 83 | + $picture->resize('app/public/users/'.$this->id.'.'.$ext); |
|
| 84 | + $this->pathPicture = 'app/public/users/'.$this->id.'.'.$ext; |
|
| 85 | 85 | } |
| 86 | 86 | app(UserRepository::class)->update($this); |
| 87 | 87 | } |