cms/app/Http/Controllers/Admin/Profile/ProfileUpdateController.php
Funky Waddle 37ed997989 feat(cms): initialize Laravel project structure and core CMS files
- Added standard Laravel directory structure and configuration.

- Included Svelte and Tailwind configuration for the admin interface.

- Added core PHPUnit and testing scripts.
2026-04-13 12:48:06 -05:00

42 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\Profile;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Profile\UpdateProfileRequest;
use App\Services\ProfileService;
use Illuminate\Support\Facades\Auth;
use Exception;
/**
* Handle Profile Update requests.
*
* @package App\Http\Controllers\Admin\Profile
*/
class ProfileUpdateController extends Controller
{
/**
* Handle the incoming request.
*
* @param UpdateProfileRequest $request
* @param ProfileService $profileService
* @return \Illuminate\Http\RedirectResponse
*/
public function __invoke(UpdateProfileRequest $request, ProfileService $profileService)
{
$user = Auth::user();
try {
if ($profileService->update($user, $request->validated())) {
return redirect()
->route('admin.profile.edit')
->with('status', 'profile-updated');
}
} catch (Exception $e) {
return back()->withInput()->withErrors(['error' => $e->getMessage()]);
}
return back()->withInput()->with('error', 'Failed to update profile.');
}
}