diff --git a/code/app/Http/Controllers/UsersController.php b/code/app/Http/Controllers/UsersController.php index 17870b3b..c0d3a91e 100644 --- a/code/app/Http/Controllers/UsersController.php +++ b/code/app/Http/Controllers/UsersController.php @@ -58,8 +58,8 @@ public function revisioned(Request $request, $id) public function promote(Request $request, $id) { - return $this->easyExecute(function() use ($id) { - $subject = $this->service->promoteFriend($id); + return $this->easyExecute(function() use ($id, $request) { + $subject = $this->service->promoteFriend($request->all(), $id); return $this->commonSuccessResponse($subject); }); } diff --git a/code/app/Models/Concerns/ContactableTrait.php b/code/app/Models/Concerns/ContactableTrait.php index a1f2f66a..afe15127 100644 --- a/code/app/Models/Concerns/ContactableTrait.php +++ b/code/app/Models/Concerns/ContactableTrait.php @@ -16,7 +16,7 @@ trait ContactableTrait { public function contacts(): MorphMany { - return $this->morphMany('App\Contact', 'target'); + return $this->morphMany(Contact::class, 'target'); } public function updateContacts($request) diff --git a/code/app/Services/UsersService.php b/code/app/Services/UsersService.php index 64186ffc..c0df3f66 100644 --- a/code/app/Services/UsersService.php +++ b/code/app/Services/UsersService.php @@ -284,7 +284,7 @@ public function revisioned($id, $approved) DB::commit(); } - public function promoteFriend($id) + public function promoteFriend($request, $id) { $admin = $this->ensureAuth(['users.admin' => 'gas']); @@ -299,6 +299,11 @@ public function promoteFriend($id) $user->parent_id = null; $user->save(); + $email = $request['email'] ?? null; + if ($email) { + $user->addContact('email', $email); + } + return $user; } diff --git a/code/resources/views/commons/columns.blade.php b/code/resources/views/commons/columns.blade.php new file mode 100644 index 00000000..80a22fe9 --- /dev/null +++ b/code/resources/views/commons/columns.blade.php @@ -0,0 +1,16 @@ +
{{ _i('Cliccando "Salva", questo utente diventerà un utente regolare. Gli sarà assegnato il ruolo %s, avrà una propria contabilità, e non potrà più essere amministrato da %s. Sarà preservato lo storico delle sue prenotazioni, ma tutti i suoi pagamenti pregressi resteranno addebitati a %s.', roleByIdentifier('user')->name, $user->parent->printableName(), $user->parent->printableName()) }}
+ + @if(blank($user->email)) +