diff --git a/CHANGELOG.md b/CHANGELOG.md index 8654019c..73e26522 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [2.7.5] + +### Fixed +- only 50 users visible on users overview +- user not receiving invitation mail when adding to platform +- link inside the register confirmation mail did not work. + ## [2.7.4] ### Fixed @@ -220,6 +227,7 @@ - Remove cancel button +[2.7.5]: https://github.com/StadGent/laravel_site_opening-hours/compare/2.7.4...2.7.5 [2.7.4]: https://github.com/StadGent/laravel_site_opening-hours/compare/2.7.3...2.7.4 [2.7.3]: https://github.com/StadGent/laravel_site_opening-hours/compare/2.7.2...2.7.3 [2.7.2]: https://github.com/StadGent/laravel_site_opening-hours/compare/2.7.1...2.7.2 diff --git a/app/Repositories/EloquentRepository.php b/app/Repositories/EloquentRepository.php index 3792fae3..7bb7439f 100644 --- a/app/Repositories/EloquentRepository.php +++ b/app/Repositories/EloquentRepository.php @@ -13,9 +13,15 @@ public function __construct($model) $this->model = $model; } - public function getAll($limit = 50, $offset = 0) + public function getAll($limit = null, $offset = null) { - return $this->model->take($limit)->skip($offset)->get()->toArray(); + $query = $this->model->take($limit); + + if (!is_null($offset)) { + $query->skip($offset); + } + + return $query->get()->toArray(); } public function store(array $properties) diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 1c075102..1769d337 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -64,9 +64,15 @@ public function getById($userId) * * @return array */ - public function getAll($limit = 50, $offset = 0) + public function getAll($limit = null, $offset = null) { - $users = $this->model->take($limit)->skip($offset)->get(); + $query = $this->model->take($limit); + + if (!is_null($offset)) { + $query->skip($offset); + } + + $users = $query->get(); $results = []; diff --git a/app/Services/UserService.php b/app/Services/UserService.php index e3ef7339..337f01d1 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -124,21 +124,21 @@ public function createNewUser($email) */ public function setRolesToUser($email, Role $role, Collection $services = null) { - $user = User::where('email', $email)->firstOrCreate(['email' => $email]); + $user = User::where('email', $email)->first(); - $newUser = $user->wasRecentlyCreated; + if (is_null($user)) { + $user = $this->createNewUser($email); + } $this->attachRoleToUser($user, $role); foreach ($services as $service) { - $this->linkUserToService($user, $service, $role, $newUser); - } - - if (!$newUser) { - // Send mail with overview of added services. - Mail::to($user)->send(new SendInviteConfirmation($user, $services)); + $this->linkUserToService($user, $service, $role); } - + + // Send mail with overview of added services. + Mail::to($user)->send(new SendInviteConfirmation($user, $services)); + $user->role = $role->name; return $user;