source: app/Http/Controllers/Dashboard/SettingsController.php@ 120759b

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

added documents crud, added last_seen_to_user, edited views

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[194a359]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;
[24a616f]11use App\Http\Requests\Dashboard\UpdateUserData;
12use App\Http\Requests\Dashboard\UpdateUserRequest;
[194a359]13use App\Http\Requests\Dashboard\UsernameSettingsRequest;
14use App\Http\Requests\Dashboard\UserProfileSettingsRequest;
15use App\Models\Post;
16use App\Models\Role;
17use App\Models\User;
18use App\Models\UserProfile;
19use Illuminate\Support\Str;
20use Illuminate\Http\Request;
21use App\Http\Controllers\Controller;
22use Illuminate\Support\Facades\File;
23use Illuminate\Support\Facades\Hash;
24use App\Notifications\VerifyNewEmail;
25use Illuminate\Support\Facades\Storage;
26use Propaganistas\LaravelPhone\PhoneNumber;
27use Propaganistas\LaravelIntl\Facades\Country;
28
29class 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}
Note: See TracBrowser for help on using the repository browser.