ldc-cocotte/app/Http/Controllers/Fo/Customers/PasswordController.php
Jérémy Munsch 74ab9b3041
refactor: reorganize imports across multiple controllers and jobs
This commit refactors the import statements in various controllers and jobs
to improve code organization and readability. Unused imports were removed,
and necessary imports were added to ensure proper functionality.
2026-11-10 18:15:32 +01:00

49 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers\Fo\Customers;
use App\Contracts\Executor;
use App\Cqs\Actions\Crm\UpdateCustomerPassword;
use App\Http\Controllers\Controller;
use App\Http\Requests\Fo\Customer\UpdatePasswordRequest;
use App\Models\Customer;
use Domain\Models\ValueObjects\CrmCustomer;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Validation\ValidationException;
class PasswordController extends Controller
{
public function __construct(
private readonly Executor $executor
) {
}
public function editPassword(): View
{
$this->authorize('manageOwnProfile', Customer::class);
return view('fo.customer.edit.password');
}
public function editPasswordSubmit(UpdatePasswordRequest $request, UpdateCustomerPassword $updateCustomerPassword): RedirectResponse
{
$this->authorize('manageOwnProfile', Customer::class);
$result = $this->executor->execute(
$updateCustomerPassword,
$request->toUpdateCustomerPasswordInput()
);
return match (true) {
$result->result instanceof CrmCustomer => back()
->with('success', trans('Password updated')),
$result->result instanceof ValidationException => back()
->withErrors($result->result->errors()),
$result->result === false => back()
->withErrors(trans('An error occurred, please try again later.')),
};
}
}