source: app/Http/Controllers/Dashboard/SettingsController.php@ 194a359

develop
Last change on this file since 194a359 was 194a359, checked in by beratkjufliju <kufliju@…>, 3 years ago

added departments, edited users and added user settings

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