|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace App\Http\Controllers; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use App\Http\Common\Form\UserForm; |
|
8
|
|
|
use App\Src\UseCases\Domain\Organizations\GetOrganization; |
|
9
|
|
|
use App\Src\UseCases\Domain\Users\EditUser; |
|
10
|
|
|
use App\Src\UseCases\Domain\Users\GetUser; |
|
11
|
|
|
use App\Src\UseCases\Domain\Users\GetUserStats; |
|
12
|
|
|
use Illuminate\Http\Request; |
|
13
|
|
|
use Illuminate\Support\Facades\Auth; |
|
14
|
|
|
|
|
15
|
|
|
class ProfileController extends Controller |
|
16
|
|
|
{ |
|
17
|
|
|
public function showEditProfile(GetUser $getUser, GetOrganization $getOrganization, GetUserStats $getUserStats) |
|
18
|
|
|
{ |
|
19
|
|
|
$user = $getUser->get(Auth::user()->uuid); |
|
20
|
|
|
if($user->organizationId() !== null) { |
|
21
|
|
|
$organization = $getOrganization->get($user->organizationId()); |
|
22
|
|
|
} |
|
23
|
|
|
$stats = $getUserStats->get(Auth::user()->uuid); |
|
24
|
|
|
return view('users/edit_form', [ |
|
25
|
|
|
'user' => $user->toArray(), |
|
26
|
|
|
'stats' => $stats->toArray(), |
|
27
|
|
|
'organization' => isset($organization) ? $organization->toArray() : null, |
|
28
|
|
|
'action' => route('user.edit.profile') |
|
29
|
|
|
]); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function processEditProfile(Request $request, EditUser $editUser, UserForm $form) |
|
33
|
|
|
{ |
|
34
|
|
|
$userId = Auth::user()->uuid; |
|
35
|
|
|
list($firstname, $lastname, $email, $picture) = $form->process(); |
|
36
|
|
|
$editUser->edit($userId, $email, $firstname, $lastname, $picture); |
|
37
|
|
|
$request->session()->flash('notif_msg', __('users.message.profile.updated')); |
|
38
|
|
|
return redirect()->back(); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|