/
Shamaeva2
/
coursework.local
Обзор
Документация
Войти
/
Shamaeva2
/
coursework.local
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/Http/Controllers/Auth/ProfileController.php
57 строк
1 KB
Шамаева Виктория Сергеевна
аватар для пользователей
19 июн 2026, 14:19
19 июн 2026, 14:19
f0087d6
Код
Авторство
О чём код?
<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Http\Requests\UpdateProfileRequest; use Inertia\Inertia; use Inertia\Response; use App\Models\User; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\Storage; class ProfileController extends Controller { /** * Отображает страницу. */ public function index(): Response { return Inertia::render('auth/Profile'); } /** * редактирование профия пользователя */ public function edit(User $profile): Response { return Inertia::render('auth/ProfileEdit', [ 'user' => $profile ]); } /** * Update the specified resource in storage. */ public function update(UpdateProfileRequest $request, User $profile): RedirectResponse { $data = $request->validated(); if ($request->hasFile('avatar')) { $data['avatar_path'] = $request->file('avatar')->store('avatars', 'public'); // Получение публичного диска. $disk = Storage::disk('public'); if ($profile->avatar_path && $disk->exists($profile->avatar_path)) { $disk->delete($profile->avatar_path); } } $profile->update($data); return redirect()->route('profile.index'); } }