1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Controllers\Dashboard;
|
---|
4 |
|
---|
5 | use App\Helpers\Alert;
|
---|
6 | use App\Http\Requests\Dashboard\EmailSettingsRequest;
|
---|
7 | use App\Http\Requests\Dashboard\NewUserRequest;
|
---|
8 | use App\Http\Requests\Dashboard\PasswordSettingsRequest;
|
---|
9 | use App\Http\Requests\Dashboard\PhotosSettingsRequest;
|
---|
10 | use App\Http\Requests\Dashboard\SocialLinksSettingsRequest;
|
---|
11 | use App\Http\Requests\Dashboard\UpdateUserData;
|
---|
12 | use App\Http\Requests\Dashboard\UpdateUserRequest;
|
---|
13 | use App\Http\Requests\Dashboard\UsernameSettingsRequest;
|
---|
14 | use App\Http\Requests\Dashboard\UserProfileSettingsRequest;
|
---|
15 | use App\Models\Post;
|
---|
16 | use App\Models\Role;
|
---|
17 | use App\Models\User;
|
---|
18 | use App\Models\UserProfile;
|
---|
19 | use Illuminate\Support\Str;
|
---|
20 | use Illuminate\Http\Request;
|
---|
21 | use App\Http\Controllers\Controller;
|
---|
22 | use Illuminate\Support\Facades\File;
|
---|
23 | use Illuminate\Support\Facades\Hash;
|
---|
24 | use App\Notifications\VerifyNewEmail;
|
---|
25 | use Illuminate\Support\Facades\Storage;
|
---|
26 | use Propaganistas\LaravelPhone\PhoneNumber;
|
---|
27 | use Propaganistas\LaravelIntl\Facades\Country;
|
---|
28 |
|
---|
29 | class SettingsController extends Controller
|
---|
30 | {
|
---|
31 | public function settings()
|
---|
32 | {
|
---|
33 | return view("dashboard.settings.index")->with([
|
---|
34 | "user" => auth()->user(),
|
---|
35 | "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get()
|
---|
36 | ]);
|
---|
37 | }
|
---|
38 |
|
---|
39 | public function updateUsername(UsernameSettingsRequest $request)
|
---|
40 | {
|
---|
41 | $user = auth()->user();
|
---|
42 | $user->username = $request->username;
|
---|
43 | $user->save();
|
---|
44 |
|
---|
45 | auth()->logout();
|
---|
46 | session()->flush();
|
---|
47 |
|
---|
48 | return redirect()->route("auth.loginShow");
|
---|
49 | }
|
---|
50 |
|
---|
51 | public function updatePassword(PasswordSettingsRequest $request)
|
---|
52 | {
|
---|
53 | $user = auth()->user();
|
---|
54 | $user->password = bcrypt($request->password);
|
---|
55 | $user->save();
|
---|
56 |
|
---|
57 | auth()->logout();
|
---|
58 | session()->flush();
|
---|
59 |
|
---|
60 | return redirect()->route("auth.loginShow");
|
---|
61 | }
|
---|
62 |
|
---|
63 | public function updateEmail(EmailSettingsRequest $request)
|
---|
64 | {
|
---|
65 | $user = auth()->user();
|
---|
66 |
|
---|
67 | $user->email = $request->email;
|
---|
68 | $user->is_active = false;
|
---|
69 | $user->security_code = $user->generateSecurityCode();
|
---|
70 | $user->verify_token = $user->generateVerifyToken();
|
---|
71 |
|
---|
72 | $user->save();
|
---|
73 |
|
---|
74 | $user->notify(new VerifyNewEmail($user));
|
---|
75 |
|
---|
76 | auth()->logout();
|
---|
77 | session()->flush();
|
---|
78 |
|
---|
79 | return redirect()->route("auth.loginShow");
|
---|
80 | }
|
---|
81 |
|
---|
82 | }
|
---|