Skip to content
This repository was archived by the owner on Mar 26, 2022. It is now read-only.

Commit f6b5a26

Browse files
domonkos2001kdmnkvagrant
authored
Edit personal information (#527)
* Adding function to UserController, and modifie personalinformationblade * #365 Edit all user attributs * #365 * Update personal-information.blade.php * deleted unnecessary files * fixed package-lock.json * merged the functions * address properties * sync package-lock with uran-2.x * fixed the tests * fix formatting * fix formatting Co-authored-by: Katkó Dominik <[email protected]> Co-authored-by: vagrant <vagrant@homestead> Co-authored-by: Katkó Dominik <[email protected]>
1 parent bc1b577 commit f6b5a26

File tree

5 files changed

+216
-52
lines changed

5 files changed

+216
-52
lines changed

app/Http/Controllers/Secretariat/UserController.php

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,38 @@ public function __construct()
3131
$this->middleware('auth');
3232
}
3333

34-
public function updateEmail(Request $request)
34+
public function update(Request $request)
3535
{
3636
$user = Auth::user();
3737

3838
$validator = Validator::make($request->all(), [
39-
'email' => 'required|email|max:225|unique:users',
39+
//only one should exist at a time
40+
'email' => 'email|max:225|unique:users',
41+
'phone_number' => 'string|min:16|max:18',
42+
'mothers_name' => 'string|max:225',
43+
'place_of_birth' => 'string|max:225',
44+
'date_of_birth' => 'string|max:225',
45+
'country' => 'string|max:255',
46+
'county' => 'string|max:255',
47+
'zip_code' => 'string|max:31',
48+
'city' => 'string|max:255',
49+
'street_and_number' => 'string|max:255',
4050
]);
4151

4252
if ($validator->fails()) {
4353
return redirect()->back()
4454
->withErrors($validator)
4555
->withInput();
4656
}
47-
$user->update([
48-
'email' => $request->email,
49-
]);
50-
51-
return redirect()->back()->with('message', __('general.successful_modification'));
52-
}
53-
54-
public function updatePhone(Request $request)
55-
{
56-
$user = Auth::user();
57-
58-
if ($user->hasPersonalInformation()) {
59-
$validator = Validator::make($request->all(), [
60-
'phone_number' => 'required|string|min:16|max:18',
61-
]);
62-
63-
if ($validator->fails()) {
64-
return redirect()->back()
65-
->withErrors($validator)
66-
->withInput();
67-
}
68-
69-
$user->personalInformation->update([
70-
'phone_number' => $request->phone_number,
71-
]);
57+
if ($request->has('email')) {
58+
$user->update(['email' => $request->email]);
59+
}
60+
if ($user->hasPersonalInformation() && $request->hasAny(
61+
['place_of_birth', 'date_of_birth', 'mothers_name', 'phone_number', 'country', 'county', 'zip_code', 'city', 'street_and_number']
62+
)) {
63+
$user->personalInformation->update($request->all());
7264
}
65+
//TODO: educational information
7366

7467
return redirect()->back()->with('message', __('general.successful_modification'));
7568
}

resources/views/auth/user.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</div>
2121
</div>
2222
{{-- Personal information --}}
23-
@include('user.personal-information', ['user' => $user, 'modifiable_email' => true, 'modifiable_phone' => true])
23+
@include('user.personal-information', ['user' => $user, 'modifiable' => true])
2424
{{-- Educational information --}}
2525
@include('user.educational-information', ['user' => $user])
2626

@@ -63,4 +63,4 @@ class="validate @error('new_password') invalid @enderror">
6363
</div>
6464
</div>
6565
</div>
66-
@endsection
66+
@endsection

0 commit comments

Comments
 (0)