%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/loslex/demo/app/Http/Controllers/
Upload File :
Create Path :
Current File : //www/loslex/demo/app/Http/Controllers/ProfileController.php

<?php

namespace App\Http\Controllers;

use App\Http\Requests\ProfileUpdateRequest;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect;
use Illuminate\View\View;

class ProfileController extends Controller
{
    /* Display welvcome page for new users */
    public function welcome(): View
    {
        return view('profile.welcome-' . App::currentLocale());
    }

    /* Display the user's profile form. */
    public function edit(Request $request): View
    {
        return view('profile.edit', ['user' => $request->user()]);
    }

    /* Update the user's profile information. */
    public function update(ProfileUpdateRequest $request): RedirectResponse
    {
        $request->user()->fill($request->validated());

        if ($request->user()->isDirty('email')) {
            $request->user()->email_verified_at = null;
        }

        $originals = Arr::only($request->user()->getOriginal(), array_keys($request->user()->getDirty()));
        $request->user()->save();

        Log::info("User {$request->user()->username} updated his profile", [
            'user' => $request->user()->id,
            'originals' => $originals,
            'changed' => $request->user()->getChanges()
        ]);

        return Redirect::route('profile.edit')->with('status', 'profile-updated');
    }

    /* Delete the user's account. */
    public function destroy(Request $request): RedirectResponse
    {
        $request->validateWithBag('userDeletion', [
            'password' => ['required', 'current_password'],
        ]);

        $user = $request->user();

        Auth::logout();

        $user->delete();

        $request->session()->invalidate();
        $request->session()->regenerateToken();

        return Redirect::to('/');
    }
}

Zerion Mini Shell 1.0