[194a359] | 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\UsernameSettingsRequest;
|
---|
| 12 | use App\Http\Requests\Dashboard\UserProfileSettingsRequest;
|
---|
| 13 | use App\Models\Post;
|
---|
| 14 | use App\Models\Role;
|
---|
| 15 | use App\Models\User;
|
---|
| 16 | use App\Models\UserProfile;
|
---|
| 17 | use Illuminate\Support\Str;
|
---|
| 18 | use Illuminate\Http\Request;
|
---|
| 19 | use App\Http\Controllers\Controller;
|
---|
| 20 | use Illuminate\Support\Facades\File;
|
---|
| 21 | use Illuminate\Support\Facades\Hash;
|
---|
| 22 | use App\Notifications\VerifyNewEmail;
|
---|
| 23 | use Illuminate\Support\Facades\Storage;
|
---|
| 24 | use Propaganistas\LaravelPhone\PhoneNumber;
|
---|
| 25 | use Propaganistas\LaravelIntl\Facades\Country;
|
---|
| 26 |
|
---|
| 27 | class 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 | }
|
---|