source: app/Http/Controllers/Dashboard/SettingsController.php@ d795fa6

develop
Last change on this file since d795fa6 was d795fa6, checked in by Berat Kjufliju <kufliju@…>, 3 years ago

added validation to blades

  • Property mode set to 100644
File size: 1.8 KB
Line 
1<?php
2
3namespace App\Http\Controllers\Dashboard;
4
5use App\Http\Requests\Dashboard\EmailSettingsRequest;
6use App\Http\Requests\Dashboard\PasswordSettingsRequest;
7use App\Http\Requests\Dashboard\UsernameSettingsRequest;
8use App\Models\User;
9use App\Http\Controllers\Controller;
10use App\Notifications\VerifyNewEmail;
11use Carbon\Carbon;
12
13class SettingsController extends Controller
14{
15 public function settings()
16 {
17 return view("dashboard.settings.index")->with([
18 "user" => auth()->user(),
19 "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get(),
20 ]);
21 }
22
23 public function updateUsername(UsernameSettingsRequest $request)
24 {
25// if($request->validated()){
26// $user = auth()->user();
27// $user->username = $request->username;
28// $user->save();
29//
30// auth()->logout();
31// session()->flush();
32//
33// return redirect()->route("auth.loginShow");
34// }
35// else {
36 return back()->withInput(['tab'=>'security']);
37 // }
38 }
39
40 public function updatePassword(PasswordSettingsRequest $request)
41 {
42 $user = auth()->user();
43 $user->password = bcrypt($request->password);
44 $user->save();
45
46 auth()->logout();
47 session()->flush();
48
49 return redirect()->route("auth.loginShow");
50 }
51
52 public function updateEmail(EmailSettingsRequest $request)
53 {
54 $user = auth()->user();
55
56 $user->email = $request->email;
57 $user->is_active = false;
58 $user->security_code = $user->generateSecurityCode();
59 $user->verify_token = $user->generateVerifyToken();
60
61 $user->save();
62
63 $user->notify(new VerifyNewEmail($user));
64
65 auth()->logout();
66 session()->flush();
67
68 return redirect()->route("auth.loginShow");
69 }
70
71}
Note: See TracBrowser for help on using the repository browser.