ldc-boutique-cnc-sable/app/Http/Controllers/Bo/FaqsController.php
Jérémy Munsch 3b3997d547
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-27 09:58:44 +01:00

104 lines
2.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers\Bo;
use App\Actions\Faqs\CreateFaq;
use App\Actions\Faqs\DeleteFaq;
use App\Actions\Faqs\DeleteFaqInput;
use App\Actions\Faqs\UpdateFaq;
use App\Contracts\Executor;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\Faqs\StoreFaqRequest;
use App\Http\Requests\Bo\Faqs\UpdateFaqRequest;
use App\Lib\Helpers\RequestHelper;
use App\Models\Faq;
use App\Queries\Faqs\GetPaginatedFaqsQuery;
use App\Queries\Faqs\GetPaginatedFaqsQueryInput;
use App\Traits\Controllers\ChangesModelOrder;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class FaqsController extends Controller
{
use ChangesModelOrder;
public function __construct(
private readonly Executor $executor,
) {
}
public function index(Request $request, GetPaginatedFaqsQuery $query): View
{
$this->authorize('viewAny', Faq::class);
$pagination = RequestHelper::pagination($request);
$faqs = $this->executor->execute(
$query,
new GetPaginatedFaqsQueryInput(
pagination: $pagination,
)
);
return view('bo.faqs.index', compact('faqs'));
}
public function create(): View
{
$this->authorize('create', Faq::class);
return view('bo.faqs.create');
}
public function store(StoreFaqRequest $request, CreateFaq $action): RedirectResponse
{
$this->authorize('create', Faq::class);
$faq = $this->executor->execute(
$action,
$request->toCreateFaqInput(),
);
return to_route('bo.faqs.edit', $faq)
->with('success', trans('crud.messages.has_been_created', [
'model' => Str::ucfirst(trans_choice('models.classes.faqs', 1)),
]));
}
public function edit(Faq $faq): View
{
$this->authorize('update', $faq);
return view('bo.faqs.edit', compact('faq'));
}
public function update(UpdateFaqRequest $request, Faq $faq, UpdateFaq $action): RedirectResponse
{
$this->authorize('update', $faq);
$this->executor->execute(
$action,
$request->toUpdateFaqInput($faq),
);
return to_route('bo.faqs.edit', $faq)
->with('success', trans('crud.messages.has_been_updated', [
'model' => Str::ucfirst(trans_choice('models.classes.faqs', 1)),
]));
}
public function destroy(Faq $faq, DeleteFaq $action): RedirectResponse
{
$this->authorize('delete', $faq);
$this->executor->execute($action, new DeleteFaqInput(faq: $faq));
return to_route('bo.faqs.index')
->with('warning', trans('crud.messages.has_been_deleted', [
'model' => Str::ucfirst(trans_choice('models.classes.faqs', \INF)),
]));
}
}