From 9ebf712170a71a1ee8f18a803f607c4e7d858e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 1 Oct 2026 11:25:05 +0200 Subject: [PATCH] refactor(cqs): complete Fo/PageController, BO FormRequest input mappings, and decouple Directories --- .../Controllers/Bo/DiscountsController.php | 19 +----- app/Http/Controllers/Bo/FaqsController.php | 13 +--- app/Http/Controllers/Bo/PageController.php | 12 +--- .../Bo/PickupExceptionsController.php | 17 +----- app/Http/Controllers/Bo/RangesController.php | 32 +--------- app/Http/Controllers/Bo/ShopsController.php | 35 +---------- app/Http/Controllers/Bo/SlidesController.php | 59 ++----------------- app/Http/Controllers/Bo/TagsController.php | 13 +--- .../Fo/Auth/ForgotPasswordController.php | 22 ++++--- .../Controllers/Fo/Pages/PageController.php | 17 +++--- .../Bo/Discounts/StoreDiscountRequest.php | 12 ++++ .../Bo/Discounts/UpdateDiscountRequest.php | 14 +++++ app/Http/Requests/Bo/Faqs/StoreFaqRequest.php | 9 +++ .../Requests/Bo/Faqs/UpdateFaqRequest.php | 11 ++++ .../Requests/Bo/Pages/UpdatePageRequest.php | 17 +++++- .../StorePickupExceptionRequest.php | 11 ++++ .../UpdatePickupExceptionRequest.php | 13 ++++ .../Requests/Bo/Ranges/StoreRangeRequest.php | 19 ++++++ .../Requests/Bo/Ranges/UpdateRangeRequest.php | 21 +++++++ .../Requests/Bo/Shops/StoreShopRequest.php | 14 +++++ .../UpdateShopPickupExceptionsRequest.php | 10 ++++ .../Requests/Bo/Shops/UpdateShopRequest.php | 16 +++++ .../Requests/Bo/Slides/StoreSlideRequest.php | 39 ++++++++++++ .../Requests/Bo/Slides/UpdateSlideRequest.php | 19 ++++++ app/Http/Requests/Bo/Tags/StoreTagRequest.php | 9 +++ .../Requests/Bo/Tags/UpdateTagRequest.php | 11 ++++ .../Customers/GetCustomerByEmailQuery.php | 29 +++++++++ .../GetCustomerByEmailQueryInput.php | 16 +++++ app/Queries/Dashboard/GetBoDashboardQuery.php | 7 +-- app/Queries/Faqs/GetFaqsQuery.php | 35 +++++++++++ app/Services/OrderService.php | 37 +++++------- .../Customers/GetCustomerByEmailQueryTest.php | 47 +++++++++++++++ .../App/Queries/Faqs/GetFaqsQueryTest.php | 41 +++++++++++++ 33 files changed, 472 insertions(+), 224 deletions(-) create mode 100644 app/Queries/Customers/GetCustomerByEmailQuery.php create mode 100644 app/Queries/Customers/GetCustomerByEmailQueryInput.php create mode 100644 app/Queries/Faqs/GetFaqsQuery.php create mode 100644 tests/Integration/WithApp/App/Queries/Customers/GetCustomerByEmailQueryTest.php create mode 100644 tests/Integration/WithApp/App/Queries/Faqs/GetFaqsQueryTest.php diff --git a/app/Http/Controllers/Bo/DiscountsController.php b/app/Http/Controllers/Bo/DiscountsController.php index 7e14b17a..3b44f9be 100644 --- a/app/Http/Controllers/Bo/DiscountsController.php +++ b/app/Http/Controllers/Bo/DiscountsController.php @@ -5,11 +5,9 @@ declare(strict_types=1); namespace App\Http\Controllers\Bo; use App\Actions\Discounts\CreateDiscount; -use App\Actions\Discounts\CreateDiscountInput; use App\Actions\Discounts\DeleteDiscount; use App\Actions\Discounts\DeleteDiscountInput; use App\Actions\Discounts\UpdateDiscount; -use App\Actions\Discounts\UpdateDiscountInput; use App\Contracts\Executor; use App\Http\Controllers\Controller; use App\Http\Requests\Bo\Discounts\StoreDiscountRequest; @@ -69,13 +67,7 @@ class DiscountsController extends Controller $discount = $this->executor->execute( $action, - new CreateDiscountInput( - type: $request->toDiscountType(), - value: $request->toDiscountValue(), - is_old_price_displayed: $request->boolean('is_old_price_displayed'), - period: $request->toDatePeriod(), - associatedProductsIds: $request->toAssociatedProductsIds(), - ), + $request->toCreateDiscountInput(), ); return to_route('bo.discounts.edit', $discount) @@ -107,14 +99,7 @@ class DiscountsController extends Controller $this->executor->execute( $action, - new UpdateDiscountInput( - discount: $discount, - type: $request->toDiscountType(), - value: $request->toDiscountValue(), - is_old_price_displayed: $request->boolean('is_old_price_displayed'), - period: $request->toDatePeriod(), - associatedProductsIds: $request->toAssociatedProductsIds(), - ), + $request->toUpdateDiscountInput($discount), ); return to_route('bo.discounts.edit', $discount) diff --git a/app/Http/Controllers/Bo/FaqsController.php b/app/Http/Controllers/Bo/FaqsController.php index 270373f7..dbb1733c 100644 --- a/app/Http/Controllers/Bo/FaqsController.php +++ b/app/Http/Controllers/Bo/FaqsController.php @@ -5,11 +5,9 @@ declare(strict_types=1); namespace App\Http\Controllers\Bo; use App\Actions\Faqs\CreateFaq; -use App\Actions\Faqs\CreateFaqInput; use App\Actions\Faqs\DeleteFaq; use App\Actions\Faqs\DeleteFaqInput; use App\Actions\Faqs\UpdateFaq; -use App\Actions\Faqs\UpdateFaqInput; use App\Contracts\Executor; use App\Http\Controllers\Controller; use App\Http\Requests\Bo\Faqs\StoreFaqRequest; @@ -60,10 +58,7 @@ class FaqsController extends Controller $faq = $this->executor->execute( $action, - new CreateFaqInput( - question: $request->string('question')->value(), - answer: $request->string('answer')->value(), - ), + $request->toCreateFaqInput(), ); return to_route('bo.faqs.edit', $faq) @@ -85,11 +80,7 @@ class FaqsController extends Controller $this->executor->execute( $action, - new UpdateFaqInput( - faq: $faq, - question: $request->string('question')->value(), - answer: $request->string('answer')->value(), - ), + $request->toUpdateFaqInput($faq), ); return to_route('bo.faqs.edit', $faq) diff --git a/app/Http/Controllers/Bo/PageController.php b/app/Http/Controllers/Bo/PageController.php index 218e37ec..d7b54129 100644 --- a/app/Http/Controllers/Bo/PageController.php +++ b/app/Http/Controllers/Bo/PageController.php @@ -5,13 +5,11 @@ declare(strict_types=1); namespace App\Http\Controllers\Bo; use App\Actions\Pages\UpdatePage; -use App\Actions\Pages\UpdatePageInput; use App\Contracts\Executor; use App\Dto\PageDto; use App\Http\Controllers\Controller; use App\Http\Requests\Bo\Pages\UpdatePageRequest as PagesUpdatePageRequest; use App\Models\Page; -use Domain\Models\ValueObjects\SeoMetadata; use Illuminate\Contracts\View\View; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Str; @@ -38,15 +36,7 @@ class PageController extends Controller $this->executor->execute( $action, - new UpdatePageInput( - page: $page, - seo: new SeoMetadata( - title: $request->string('seo_title')->value(), - description: $request->string('seo_description')->value(), - ), - title: $request->filled('title') ? $request->string('title')->value() : null, - content: $request->string('content')->value(), - ), + $request->toUpdatePageInput($page), ); return to_route('bo.pages.edit', $page->slug->value()) diff --git a/app/Http/Controllers/Bo/PickupExceptionsController.php b/app/Http/Controllers/Bo/PickupExceptionsController.php index 1535476c..eb2e655c 100644 --- a/app/Http/Controllers/Bo/PickupExceptionsController.php +++ b/app/Http/Controllers/Bo/PickupExceptionsController.php @@ -5,11 +5,9 @@ declare(strict_types=1); namespace App\Http\Controllers\Bo; use App\Actions\PickupExceptions\CreatePickupException; -use App\Actions\PickupExceptions\CreatePickupExceptionInput; use App\Actions\PickupExceptions\DeletePickupException; use App\Actions\PickupExceptions\DeletePickupExceptionInput; use App\Actions\PickupExceptions\UpdatePickupException; -use App\Actions\PickupExceptions\UpdatePickupExceptionInput; use App\Contracts\Executor; use App\Dto\PickupExceptionDto; use App\Http\Controllers\Controller; @@ -57,12 +55,7 @@ class PickupExceptionsController extends Controller $pickupException = $this->executor->execute( $action, - new CreatePickupExceptionInput( - date: $request->string('date')->value(), - label: $request->string('label')->value(), - repeatable: $request->boolean('repeatable'), - repeat_frequency: $request->toRepeatFrequency(), - ), + $request->toCreatePickupExceptionInput(), ); return to_route('bo.pickup-exceptions.edit', $pickupException) @@ -86,13 +79,7 @@ class PickupExceptionsController extends Controller $this->executor->execute( $action, - new UpdatePickupExceptionInput( - pickupException: $pickupException, - date: $request->string('date')->value(), - label: $request->string('label')->value(), - repeatable: $request->boolean('repeatable'), - repeat_frequency: $request->toRepeatFrequency(), - ), + $request->toUpdatePickupExceptionInput($pickupException), ); return to_route('bo.pickup-exceptions.edit', $pickupException) diff --git a/app/Http/Controllers/Bo/RangesController.php b/app/Http/Controllers/Bo/RangesController.php index f5cd914a..3b05db1d 100644 --- a/app/Http/Controllers/Bo/RangesController.php +++ b/app/Http/Controllers/Bo/RangesController.php @@ -5,11 +5,9 @@ declare(strict_types=1); namespace App\Http\Controllers\Bo; use App\Actions\Ranges\CreateRange; -use App\Actions\Ranges\CreateRangeInput; use App\Actions\Ranges\DeleteRange; use App\Actions\Ranges\DeleteRangeInput; use App\Actions\Ranges\UpdateRange; -use App\Actions\Ranges\UpdateRangeInput; use App\Contracts\Executor; use App\Dto\RangeDto; use App\Http\Controllers\Controller; @@ -20,7 +18,6 @@ use App\Queries\Ranges\GetPaginatedRangesQuery; use App\Queries\Ranges\GetPaginatedRangesQueryInput; use App\Traits\Controllers\ChangesModelOrder; use App\Traits\Controllers\TogglesModelStatus; -use Domain\Models\ValueObjects\PictureMetadata; use Illuminate\Contracts\View\View; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; @@ -63,21 +60,9 @@ class RangesController extends Controller { $this->authorize('create', Range::class); - $pictureAlt = $request->filled('picture_alt') ? $request->string('picture_alt')->value() : null; - $pictureTitle = $request->filled('picture_title') ? $request->string('picture_title')->value() : null; - $range = $this->executor->execute( $action, - new CreateRangeInput( - name: $request->string('name')->value(), - description: $request->filled('description') ? $request->string('description')->value() : null, - picture: $request->file('picture'), - pictureMetadata: new PictureMetadata( - alt: $pictureAlt, - title: $pictureTitle, - ), - status: $request->boolean('status'), - ), + $request->toCreateRangeInput(), ); return to_route('bo.ranges.edit', $range) @@ -99,22 +84,9 @@ class RangesController extends Controller { $this->authorize('update', $range); - $pictureAlt = $request->filled('picture_alt') ? $request->string('picture_alt')->value() : null; - $pictureTitle = $request->filled('picture_title') ? $request->string('picture_title')->value() : null; - $this->executor->execute( $action, - new UpdateRangeInput( - range: $range, - name: $request->string('name')->value(), - description: $request->filled('description') ? $request->string('description')->value() : null, - picture: $request->file('picture'), - pictureMetadata: new PictureMetadata( - alt: $pictureAlt, - title: $pictureTitle, - ), - status: $request->boolean('status'), - ), + $request->toUpdateRangeInput($range), ); return to_route('bo.ranges.edit', $range) diff --git a/app/Http/Controllers/Bo/ShopsController.php b/app/Http/Controllers/Bo/ShopsController.php index 5f1e5d6f..a6a34e0c 100644 --- a/app/Http/Controllers/Bo/ShopsController.php +++ b/app/Http/Controllers/Bo/ShopsController.php @@ -5,13 +5,10 @@ declare(strict_types=1); namespace App\Http\Controllers\Bo; use App\Actions\Shops\CreateShop; -use App\Actions\Shops\CreateShopInput; use App\Actions\Shops\DeleteShop; use App\Actions\Shops\DeleteShopInput; use App\Actions\Shops\UpdateShop; -use App\Actions\Shops\UpdateShopInput; use App\Actions\Shops\UpdateShopPickupExceptions; -use App\Actions\Shops\UpdateShopPickupExceptionsInput; use App\Contracts\Executor; use App\Dto\ShopDto; use App\Http\Controllers\Controller; @@ -64,20 +61,9 @@ class ShopsController extends Controller { $this->authorize('create', Shop::class); - $coordinates = $request->toCoordinates(); - $phone = $request->toPhoneNumber(); - $shop = $this->executor->execute( $action, - new CreateShopInput( - name: $request->string('name')->value(), - address: $request->string('address')->value(), - postcode: $request->string('postcode')->value(), - city: $request->string('city')->value(), - phone: $phone, - coordinates: $coordinates, - default: $request->boolean('default'), - ), + $request->toCreateShopInput(), ); return to_route('bo.shops.edit', $shop) @@ -99,21 +85,9 @@ class ShopsController extends Controller { $this->authorize('update', $shop); - $coordinates = $request->toCoordinates(); - $phone = $request->toPhoneNumber(); - $this->executor->execute( $action, - new UpdateShopInput( - shop: $shop, - name: $request->string('name')->value(), - address: $request->string('address')->value(), - postcode: $request->string('postcode')->value(), - city: $request->string('city')->value(), - phone: $phone, - coordinates: $coordinates, - default: $request->boolean('default'), - ), + $request->toUpdateShopInput($shop), ); return to_route('bo.shops.edit', $shop) @@ -163,10 +137,7 @@ class ShopsController extends Controller $this->executor->execute( $action, - new UpdateShopPickupExceptionsInput( - shop: $shop, - syncData: $request->toSyncData(), - ), + $request->toUpdateShopPickupExceptionsInput($shop), ); return back()->with('success', trans('crud.messages.has_been_updated', [ diff --git a/app/Http/Controllers/Bo/SlidesController.php b/app/Http/Controllers/Bo/SlidesController.php index 457ffe20..23651a18 100644 --- a/app/Http/Controllers/Bo/SlidesController.php +++ b/app/Http/Controllers/Bo/SlidesController.php @@ -5,11 +5,9 @@ declare(strict_types=1); namespace App\Http\Controllers\Bo; use App\Actions\Slides\CreateSlide; -use App\Actions\Slides\CreateSlideInput; use App\Actions\Slides\DeleteSlide; use App\Actions\Slides\DeleteSlideInput; use App\Actions\Slides\UpdateSlide; -use App\Actions\Slides\UpdateSlideInput; use App\Contracts\Executor; use App\Dto\SlideDto; use App\Http\Controllers\Controller; @@ -20,11 +18,9 @@ use App\Queries\Slides\GetPaginatedSlidesQuery; use App\Queries\Slides\GetPaginatedSlidesQueryInput; use App\Traits\Controllers\ChangesModelOrder; use App\Traits\Controllers\TogglesModelStatus; -use Domain\Models\ValueObjects\DatePeriod; use Illuminate\Contracts\View\View; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\UploadedFile; use Illuminate\Support\Str; class SlidesController extends Controller @@ -41,13 +37,11 @@ class SlidesController extends Controller { $this->authorize('viewAny', Slide::class); - $pagination = $request->pagination(); - $slides = $this->executor->execute( $query, new GetPaginatedSlidesQueryInput( - pagination: $pagination, - ) + pagination: $request->pagination(), + ), ); return view('bo.slides.index', compact('slides')); @@ -64,25 +58,9 @@ class SlidesController extends Controller { $this->authorize('create', Slide::class); - $period = new DatePeriod( - start: $request->filled('date_start') ? new \DateTimeImmutable($request->string('date_start')->value()) : null, - end: $request->filled('date_end') ? new \DateTimeImmutable($request->string('date_end')->value()) : null, - ); - $slide = $this->executor->execute( $action, - new CreateSlideInput( - title: $request->string('title')->value(), - text: $request->filled('text') ? $request->string('text')->value() : null, - picture: $this->resolvePicture($request), - pictureAlt: $request->filled('picture_alt') ? $request->string('picture_alt')->value() : null, - pictureTitle: $request->filled('picture_title') ? $request->string('picture_title')->value() : null, - link: $request->filled('link') ? $request->string('link')->value() : null, - linkLabel: $request->filled('link_label') ? $request->string('link_label')->value() : null, - linkNewTab: $request->boolean('link_new_tab'), - connected: $request->boolean('connected'), - period: $period, - ), + $request->toCreateSlideInput(), ); return to_route('bo.slides.edit', $slide) @@ -104,26 +82,9 @@ class SlidesController extends Controller { $this->authorize('update', $slide); - $period = new DatePeriod( - start: $request->filled('date_start') ? new \DateTimeImmutable($request->string('date_start')->value()) : null, - end: $request->filled('date_end') ? new \DateTimeImmutable($request->string('date_end')->value()) : null, - ); - $this->executor->execute( $action, - new UpdateSlideInput( - slide: $slide, - title: $request->string('title')->value(), - text: $request->filled('text') ? $request->string('text')->value() : null, - picture: $this->resolvePicture($request), - pictureAlt: $request->filled('picture_alt') ? $request->string('picture_alt')->value() : null, - pictureTitle: $request->filled('picture_title') ? $request->string('picture_title')->value() : null, - link: $request->filled('link') ? $request->string('link')->value() : null, - linkLabel: $request->filled('link_label') ? $request->string('link_label')->value() : null, - linkNewTab: $request->boolean('link_new_tab'), - connected: $request->boolean('connected'), - period: $period, - ), + $request->toUpdateSlideInput($slide), ); return to_route('bo.slides.edit', $slide) @@ -146,16 +107,4 @@ class SlidesController extends Controller 'model' => Str::ucfirst(trans_choice('models.classes.slides', 1)), ])); } - - private function resolvePicture(StoreSlideRequest | UpdateSlideRequest $request): UploadedFile | string | null - { - $file = $request->file('picture'); - if ($file instanceof UploadedFile) { - return $file; - } - - return $request->has('picture') && is_string($request->input('picture')) - ? $request->input('picture') - : null; - } } diff --git a/app/Http/Controllers/Bo/TagsController.php b/app/Http/Controllers/Bo/TagsController.php index e8f86c0f..e038b3bb 100644 --- a/app/Http/Controllers/Bo/TagsController.php +++ b/app/Http/Controllers/Bo/TagsController.php @@ -5,11 +5,9 @@ declare(strict_types=1); namespace App\Http\Controllers\Bo; use App\Actions\Tags\CreateTag; -use App\Actions\Tags\CreateTagInput; use App\Actions\Tags\DeleteTag; use App\Actions\Tags\DeleteTagInput; use App\Actions\Tags\UpdateTag; -use App\Actions\Tags\UpdateTagInput; use App\Contracts\Executor; use App\Http\Controllers\Controller; use App\Http\Requests\Bo\Tags\StoreTagRequest; @@ -63,10 +61,7 @@ class TagsController extends Controller $tag = $this->executor->execute( $action, - new CreateTagInput( - label: $request->string('label')->value(), - status: $request->boolean('status'), - ), + $request->toCreateTagInput(), ); return to_route('bo.tags.edit', $tag) @@ -88,11 +83,7 @@ class TagsController extends Controller $this->executor->execute( $action, - new UpdateTagInput( - tag: $tag, - label: $request->string('label')->value(), - status: $request->boolean('status'), - ), + $request->toUpdateTagInput($tag), ); return to_route('bo.tags.edit', $tag) diff --git a/app/Http/Controllers/Fo/Auth/ForgotPasswordController.php b/app/Http/Controllers/Fo/Auth/ForgotPasswordController.php index fff0c441..ac38c492 100644 --- a/app/Http/Controllers/Fo/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Fo/Auth/ForgotPasswordController.php @@ -4,10 +4,12 @@ declare(strict_types=1); namespace App\Http\Controllers\Fo\Auth; -use App\Contracts\Directories\CustomerDirectory; +use App\Contracts\Executor; use App\Exceptions\CustomerNotEmployedException; -use App\Models\Customer; +use App\Queries\Customers\GetCustomerByEmailQuery; +use App\Queries\Customers\GetCustomerByEmailQueryInput; use Domain\Models\ValueObjects\Email; +use Domain\Models\ValueObjects\Entities\ShopperId; use Domain\Services\ShopperService; use Illuminate\Contracts\Auth\PasswordBroker; use Illuminate\Contracts\View\View; @@ -24,8 +26,8 @@ class ForgotPasswordController extends AuthController } public function __construct( - private readonly CustomerDirectory $customerDirectory, - private readonly ShopperService $shopperService + private readonly Executor $executor, + private readonly ShopperService $shopperService, ) { $this->middleware('guest:frontend'); parent::__construct(); @@ -36,15 +38,17 @@ class ForgotPasswordController extends AuthController return view('fo.auth.passwords.email'); } - public function sendResetLinkEmail(Request $request): JsonResponse | RedirectResponse + public function sendResetLinkEmail(Request $request, GetCustomerByEmailQuery $query): JsonResponse | RedirectResponse { $this->validateEmail($request); - $customer = $this->customerDirectory - ->getCustomerByEmail(new Email($request->string('email')->toString())); + $shopperId = $this->executor->execute( + $query, + new GetCustomerByEmailQueryInput(new Email($request->string('email')->toString())), + ); - if ($customer instanceof Customer) { - $shopper = $this->shopperService->getShopperFor($customer->getId()); + if ($shopperId instanceof ShopperId) { + $shopper = $this->shopperService->getShopperFor($shopperId); if (! $shopper || ! $shopper->isActive()) { throw new CustomerNotEmployedException(); } diff --git a/app/Http/Controllers/Fo/Pages/PageController.php b/app/Http/Controllers/Fo/Pages/PageController.php index 191ae507..3efc1e5d 100644 --- a/app/Http/Controllers/Fo/Pages/PageController.php +++ b/app/Http/Controllers/Fo/Pages/PageController.php @@ -5,9 +5,10 @@ declare(strict_types=1); namespace App\Http\Controllers\Fo\Pages; use App\Contracts\Executor; +use App\Contracts\QueryInputEmpty; use App\Dto\PageDto; use App\Http\Controllers\Controller; -use App\Models\Faq; +use App\Queries\Faqs\GetFaqsQuery; use App\Queries\Pages\GetPageQuery; use App\Queries\Pages\GetPageQueryInput; use Domain\Enums\StaticPageSlug; @@ -18,6 +19,7 @@ class PageController extends Controller { public function __construct( private readonly Executor $executor, + private readonly GetPageQuery $getPageQuery, ) { } @@ -48,12 +50,13 @@ class PageController extends Controller )); } - public function faq(): View + public function faq(GetFaqsQuery $getFaqsQuery): View { - $page = $this->getPageBySlug(StaticPageSlug::FAQ); - $faqs = Faq::query() - ->orderBy('order', 'asc') - ->get(); + $page = $this->getPageBySlug(StaticPageSlug::FAQ); + $faqs = $this->executor->execute( + $getFaqsQuery, + new QueryInputEmpty() + ); return view('fo.pages.faq', compact( 'faqs', @@ -67,7 +70,7 @@ class PageController extends Controller $pageSlugInput = new GetPageQueryInput($slug); return $this->executor->execute( - new GetPageQuery(), + $this->getPageQuery, $pageSlugInput ); } diff --git a/app/Http/Requests/Bo/Discounts/StoreDiscountRequest.php b/app/Http/Requests/Bo/Discounts/StoreDiscountRequest.php index 84976446..bbf6b694 100644 --- a/app/Http/Requests/Bo/Discounts/StoreDiscountRequest.php +++ b/app/Http/Requests/Bo/Discounts/StoreDiscountRequest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Discounts; +use App\Actions\Discounts\CreateDiscountInput; use Domain\Enums\DiscountType; use Domain\Models\ValueObjects\DatePeriod; use Domain\Models\ValueObjects\DiscountValue; @@ -22,6 +23,17 @@ class StoreDiscountRequest extends FormRequest ) { } + public function toCreateDiscountInput(): CreateDiscountInput + { + return new CreateDiscountInput( + type: $this->toDiscountType(), + value: $this->toDiscountValue(), + is_old_price_displayed: $this->boolean('is_old_price_displayed'), + period: $this->toDatePeriod(), + associatedProductsIds: $this->toAssociatedProductsIds(), + ); + } + public function authorize(): bool { return $this->authService->check(); diff --git a/app/Http/Requests/Bo/Discounts/UpdateDiscountRequest.php b/app/Http/Requests/Bo/Discounts/UpdateDiscountRequest.php index 0643c3a2..1b3c8086 100644 --- a/app/Http/Requests/Bo/Discounts/UpdateDiscountRequest.php +++ b/app/Http/Requests/Bo/Discounts/UpdateDiscountRequest.php @@ -4,6 +4,20 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Discounts; +use App\Actions\Discounts\UpdateDiscountInput; +use App\Models\Discount; + class UpdateDiscountRequest extends StoreDiscountRequest { + public function toUpdateDiscountInput(Discount $discount): UpdateDiscountInput + { + return new UpdateDiscountInput( + discount: $discount, + type: $this->toDiscountType(), + value: $this->toDiscountValue(), + is_old_price_displayed: $this->boolean('is_old_price_displayed'), + period: $this->toDatePeriod(), + associatedProductsIds: $this->toAssociatedProductsIds(), + ); + } } diff --git a/app/Http/Requests/Bo/Faqs/StoreFaqRequest.php b/app/Http/Requests/Bo/Faqs/StoreFaqRequest.php index c7ccb5a5..7311bff3 100644 --- a/app/Http/Requests/Bo/Faqs/StoreFaqRequest.php +++ b/app/Http/Requests/Bo/Faqs/StoreFaqRequest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Faqs; +use App\Actions\Faqs\CreateFaqInput; use Illuminate\Foundation\Http\FormRequest; use Infrastructure\Adapters\Services\AppAdminAuthService; @@ -36,4 +37,12 @@ class StoreFaqRequest extends FormRequest 'answer' => trans('validation.custom.attributes.answer'), ]; } + + public function toCreateFaqInput(): CreateFaqInput + { + return new CreateFaqInput( + question: $this->string('question')->value(), + answer: $this->string('answer')->value(), + ); + } } diff --git a/app/Http/Requests/Bo/Faqs/UpdateFaqRequest.php b/app/Http/Requests/Bo/Faqs/UpdateFaqRequest.php index 196e4fcb..aeac3218 100644 --- a/app/Http/Requests/Bo/Faqs/UpdateFaqRequest.php +++ b/app/Http/Requests/Bo/Faqs/UpdateFaqRequest.php @@ -4,6 +4,17 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Faqs; +use App\Actions\Faqs\UpdateFaqInput; +use App\Models\Faq; + class UpdateFaqRequest extends StoreFaqRequest { + public function toUpdateFaqInput(Faq $faq): UpdateFaqInput + { + return new UpdateFaqInput( + faq: $faq, + question: $this->string('question')->value(), + answer: $this->string('answer')->value(), + ); + } } diff --git a/app/Http/Requests/Bo/Pages/UpdatePageRequest.php b/app/Http/Requests/Bo/Pages/UpdatePageRequest.php index cdc53e8f..e6ac734a 100644 --- a/app/Http/Requests/Bo/Pages/UpdatePageRequest.php +++ b/app/Http/Requests/Bo/Pages/UpdatePageRequest.php @@ -4,6 +4,9 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Pages; +use App\Actions\Pages\UpdatePageInput; +use App\Models\Page; +use Domain\Models\ValueObjects\SeoMetadata; use Illuminate\Foundation\Http\FormRequest; use Infrastructure\Adapters\Services\AppAdminAuthService; @@ -19,6 +22,19 @@ class UpdatePageRequest extends FormRequest return $this->authService->check(); } + public function toUpdatePageInput(Page $page): UpdatePageInput + { + return new UpdatePageInput( + page: $page, + seo: new SeoMetadata( + title: $this->string('seo_title')->value(), + description: $this->string('seo_description')->value(), + ), + title: $this->filled('title') ? $this->string('title')->value() : null, + content: $this->string('content')->value(), + ); + } + /** @return array */ public function rules(): array { @@ -38,7 +54,6 @@ class UpdatePageRequest extends FormRequest 'seo_description' => trans('validation.custom.attributes.seo_description'), 'title' => trans('validation.attributes.title'), 'content' => trans('validation.attributes.content'), - ]; } } diff --git a/app/Http/Requests/Bo/PickupExceptions/StorePickupExceptionRequest.php b/app/Http/Requests/Bo/PickupExceptions/StorePickupExceptionRequest.php index 5d831914..0c62e0d1 100644 --- a/app/Http/Requests/Bo/PickupExceptions/StorePickupExceptionRequest.php +++ b/app/Http/Requests/Bo/PickupExceptions/StorePickupExceptionRequest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\PickupExceptions; +use App\Actions\PickupExceptions\CreatePickupExceptionInput; use Domain\Enums\RepeatFrequency; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rules\Enum; @@ -30,6 +31,16 @@ class StorePickupExceptionRequest extends FormRequest : RepeatFrequency::from($this->string('repeat_frequency')->value()); } + public function toCreatePickupExceptionInput(): CreatePickupExceptionInput + { + return new CreatePickupExceptionInput( + date: $this->string('date')->value(), + label: $this->string('label')->value(), + repeatable: $this->boolean('repeatable'), + repeat_frequency: $this->toRepeatFrequency(), + ); + } + #[\Override] protected function prepareForValidation(): void { diff --git a/app/Http/Requests/Bo/PickupExceptions/UpdatePickupExceptionRequest.php b/app/Http/Requests/Bo/PickupExceptions/UpdatePickupExceptionRequest.php index 3950e5be..45b49699 100644 --- a/app/Http/Requests/Bo/PickupExceptions/UpdatePickupExceptionRequest.php +++ b/app/Http/Requests/Bo/PickupExceptions/UpdatePickupExceptionRequest.php @@ -4,6 +4,19 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\PickupExceptions; +use App\Actions\PickupExceptions\UpdatePickupExceptionInput; +use App\Models\PickupException; + class UpdatePickupExceptionRequest extends StorePickupExceptionRequest { + public function toUpdatePickupExceptionInput(PickupException $pickupException): UpdatePickupExceptionInput + { + return new UpdatePickupExceptionInput( + pickupException: $pickupException, + date: $this->string('date')->value(), + label: $this->string('label')->value(), + repeatable: $this->boolean('repeatable'), + repeat_frequency: $this->toRepeatFrequency(), + ); + } } diff --git a/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php b/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php index 78d9131a..b55c9d0a 100644 --- a/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php +++ b/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Ranges; +use App\Actions\Ranges\CreateRangeInput; use App\Traits\Requests\HasPicture; +use Domain\Models\ValueObjects\PictureMetadata; use Illuminate\Foundation\Http\FormRequest; use Infrastructure\Adapters\Services\AppAdminAuthService; @@ -67,4 +69,21 @@ class StoreRangeRequest extends FormRequest 'picture_title' => trans('validation.custom.attributes.picture_title'), ]; } + + public function toCreateRangeInput(): CreateRangeInput + { + $pictureAlt = $this->filled('picture_alt') ? $this->string('picture_alt')->value() : null; + $pictureTitle = $this->filled('picture_title') ? $this->string('picture_title')->value() : null; + + return new CreateRangeInput( + name: $this->string('name')->value(), + description: $this->filled('description') ? $this->string('description')->value() : null, + picture: $this->file('picture'), + pictureMetadata: new PictureMetadata( + alt: $pictureAlt, + title: $pictureTitle, + ), + status: $this->boolean('status'), + ); + } } diff --git a/app/Http/Requests/Bo/Ranges/UpdateRangeRequest.php b/app/Http/Requests/Bo/Ranges/UpdateRangeRequest.php index 4b3d904e..f8c39523 100644 --- a/app/Http/Requests/Bo/Ranges/UpdateRangeRequest.php +++ b/app/Http/Requests/Bo/Ranges/UpdateRangeRequest.php @@ -4,6 +4,27 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Ranges; +use App\Actions\Ranges\UpdateRangeInput; +use App\Models\Range; +use Domain\Models\ValueObjects\PictureMetadata; + class UpdateRangeRequest extends StoreRangeRequest { + public function toUpdateRangeInput(Range $range): UpdateRangeInput + { + $pictureAlt = $this->filled('picture_alt') ? $this->string('picture_alt')->value() : null; + $pictureTitle = $this->filled('picture_title') ? $this->string('picture_title')->value() : null; + + return new UpdateRangeInput( + range: $range, + name: $this->string('name')->value(), + description: $this->filled('description') ? $this->string('description')->value() : null, + picture: $this->file('picture'), + pictureMetadata: new PictureMetadata( + alt: $pictureAlt, + title: $pictureTitle, + ), + status: $this->boolean('status'), + ); + } } diff --git a/app/Http/Requests/Bo/Shops/StoreShopRequest.php b/app/Http/Requests/Bo/Shops/StoreShopRequest.php index d3128eca..b6dee876 100644 --- a/app/Http/Requests/Bo/Shops/StoreShopRequest.php +++ b/app/Http/Requests/Bo/Shops/StoreShopRequest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Shops; +use App\Actions\Shops\CreateShopInput; use Domain\Models\ValueObjects\Coordinates; use Domain\Models\ValueObjects\PhoneNumber as DomainPhoneNumber; use Illuminate\Foundation\Http\FormRequest; @@ -17,6 +18,19 @@ class StoreShopRequest extends FormRequest ) { } + public function toCreateShopInput(): CreateShopInput + { + return new CreateShopInput( + name: $this->string('name')->value(), + address: $this->string('address')->value(), + postcode: $this->string('postcode')->value(), + city: $this->string('city')->value(), + phone: $this->toPhoneNumber(), + coordinates: $this->toCoordinates(), + default: $this->boolean('default'), + ); + } + public function authorize(): bool { return $this->authService->check(); diff --git a/app/Http/Requests/Bo/Shops/UpdateShopPickupExceptionsRequest.php b/app/Http/Requests/Bo/Shops/UpdateShopPickupExceptionsRequest.php index 03769d61..6bd994ac 100644 --- a/app/Http/Requests/Bo/Shops/UpdateShopPickupExceptionsRequest.php +++ b/app/Http/Requests/Bo/Shops/UpdateShopPickupExceptionsRequest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Shops; +use App\Actions\Shops\UpdateShopPickupExceptionsInput; +use App\Models\Shop; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Date; use Illuminate\Support\Str; @@ -16,6 +18,14 @@ class UpdateShopPickupExceptionsRequest extends FormRequest ) { } + public function toUpdateShopPickupExceptionsInput(Shop $shop): UpdateShopPickupExceptionsInput + { + return new UpdateShopPickupExceptionsInput( + shop: $shop, + syncData: $this->toSyncData(), + ); + } + public function authorize(): bool { return $this->authService->check(); diff --git a/app/Http/Requests/Bo/Shops/UpdateShopRequest.php b/app/Http/Requests/Bo/Shops/UpdateShopRequest.php index 752eaa14..a69e6ec8 100644 --- a/app/Http/Requests/Bo/Shops/UpdateShopRequest.php +++ b/app/Http/Requests/Bo/Shops/UpdateShopRequest.php @@ -4,6 +4,22 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Shops; +use App\Actions\Shops\UpdateShopInput; +use App\Models\Shop; + class UpdateShopRequest extends StoreShopRequest { + public function toUpdateShopInput(Shop $shop): UpdateShopInput + { + return new UpdateShopInput( + shop: $shop, + name: $this->string('name')->value(), + address: $this->string('address')->value(), + postcode: $this->string('postcode')->value(), + city: $this->string('city')->value(), + phone: $this->toPhoneNumber(), + coordinates: $this->toCoordinates(), + default: $this->boolean('default'), + ); + } } diff --git a/app/Http/Requests/Bo/Slides/StoreSlideRequest.php b/app/Http/Requests/Bo/Slides/StoreSlideRequest.php index 16afaa2d..52866990 100644 --- a/app/Http/Requests/Bo/Slides/StoreSlideRequest.php +++ b/app/Http/Requests/Bo/Slides/StoreSlideRequest.php @@ -4,8 +4,11 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Slides; +use App\Actions\Slides\CreateSlideInput; use App\Traits\Requests\HasPicture; +use Domain\Models\ValueObjects\DatePeriod; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Date; use Infrastructure\Adapters\Services\AppAdminAuthService; @@ -23,6 +26,42 @@ class StoreSlideRequest extends FormRequest return $this->authService->check(); } + public function resolvePicture(): UploadedFile | string | null + { + $file = $this->file('picture'); + if ($file instanceof UploadedFile) { + return $file; + } + + return $this->has('picture') && is_string($this->input('picture')) + ? $this->input('picture') + : null; + } + + public function toDatePeriod(): DatePeriod + { + return new DatePeriod( + start: $this->filled('date_start') ? new \DateTimeImmutable($this->string('date_start')->value()) : null, + end: $this->filled('date_end') ? new \DateTimeImmutable($this->string('date_end')->value()) : null, + ); + } + + public function toCreateSlideInput(): CreateSlideInput + { + return new CreateSlideInput( + title: $this->string('title')->value(), + text: $this->filled('text') ? $this->string('text')->value() : null, + picture: $this->resolvePicture(), + pictureAlt: $this->filled('picture_alt') ? $this->string('picture_alt')->value() : null, + pictureTitle: $this->filled('picture_title') ? $this->string('picture_title')->value() : null, + link: $this->filled('link') ? $this->string('link')->value() : null, + linkLabel: $this->filled('link_label') ? $this->string('link_label')->value() : null, + linkNewTab: $this->boolean('link_new_tab'), + connected: $this->boolean('connected'), + period: $this->toDatePeriod(), + ); + } + #[\Override] protected function prepareForValidation(): void { diff --git a/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php b/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php index bf0f6f7d..135239b2 100644 --- a/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php +++ b/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php @@ -4,6 +4,25 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Slides; +use App\Actions\Slides\UpdateSlideInput; +use App\Models\Slide; + class UpdateSlideRequest extends StoreSlideRequest { + public function toUpdateSlideInput(Slide $slide): UpdateSlideInput + { + return new UpdateSlideInput( + slide: $slide, + title: $this->string('title')->value(), + text: $this->filled('text') ? $this->string('text')->value() : null, + picture: $this->resolvePicture(), + pictureAlt: $this->filled('picture_alt') ? $this->string('picture_alt')->value() : null, + pictureTitle: $this->filled('picture_title') ? $this->string('picture_title')->value() : null, + link: $this->filled('link') ? $this->string('link')->value() : null, + linkLabel: $this->filled('link_label') ? $this->string('link_label')->value() : null, + linkNewTab: $this->boolean('link_new_tab'), + connected: $this->boolean('connected'), + period: $this->toDatePeriod(), + ); + } } diff --git a/app/Http/Requests/Bo/Tags/StoreTagRequest.php b/app/Http/Requests/Bo/Tags/StoreTagRequest.php index 2ecbc471..5abff206 100644 --- a/app/Http/Requests/Bo/Tags/StoreTagRequest.php +++ b/app/Http/Requests/Bo/Tags/StoreTagRequest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Tags; +use App\Actions\Tags\CreateTagInput; use Illuminate\Foundation\Http\FormRequest; use Infrastructure\Adapters\Services\AppAdminAuthService; @@ -44,4 +45,12 @@ class StoreTagRequest extends FormRequest 'status' => trans('validation.custom.attributes.status'), ]; } + + public function toCreateTagInput(): CreateTagInput + { + return new CreateTagInput( + label: $this->string('label')->value(), + status: $this->boolean('status'), + ); + } } diff --git a/app/Http/Requests/Bo/Tags/UpdateTagRequest.php b/app/Http/Requests/Bo/Tags/UpdateTagRequest.php index 2ae1780e..5b06b028 100644 --- a/app/Http/Requests/Bo/Tags/UpdateTagRequest.php +++ b/app/Http/Requests/Bo/Tags/UpdateTagRequest.php @@ -4,6 +4,17 @@ declare(strict_types=1); namespace App\Http\Requests\Bo\Tags; +use App\Actions\Tags\UpdateTagInput; +use App\Models\Tag; + class UpdateTagRequest extends StoreTagRequest { + public function toUpdateTagInput(Tag $tag): UpdateTagInput + { + return new UpdateTagInput( + tag: $tag, + label: $this->string('label')->value(), + status: $this->boolean('status'), + ); + } } diff --git a/app/Queries/Customers/GetCustomerByEmailQuery.php b/app/Queries/Customers/GetCustomerByEmailQuery.php new file mode 100644 index 00000000..e9043aab --- /dev/null +++ b/app/Queries/Customers/GetCustomerByEmailQuery.php @@ -0,0 +1,29 @@ + + */ +final readonly class GetCustomerByEmailQuery implements Query +{ + public function __invoke(QueryInput $input): ?ShopperId + { + Assert::isInstanceOf($input, GetCustomerByEmailQueryInput::class); + + /** @var Customer|null $customer */ + $customer = Customer::query() + ->where('email', $input->email->value) + ->first(); + + return $customer?->getId(); + } +} diff --git a/app/Queries/Customers/GetCustomerByEmailQueryInput.php b/app/Queries/Customers/GetCustomerByEmailQueryInput.php new file mode 100644 index 00000000..6dcfdc56 --- /dev/null +++ b/app/Queries/Customers/GetCustomerByEmailQueryInput.php @@ -0,0 +1,16 @@ +statsService->getStats(StatsCustomerType::cases(), $input->start, $input->end); } - $employeeCount = $this->employeeDirectory->countActiveEmployees(); - $customersLinkedToEmployeeCount = $this->employeeDirectory->countActiveRegisteredEmployees(); + $employeeCount = Employee::query()->active()->count(); + $customersLinkedToEmployeeCount = Employee::query()->active()->whereHas('customer')->count(); return new GetBoDashboardQueryOutput( employeeCount: $employeeCount, diff --git a/app/Queries/Faqs/GetFaqsQuery.php b/app/Queries/Faqs/GetFaqsQuery.php new file mode 100644 index 00000000..76c4e62d --- /dev/null +++ b/app/Queries/Faqs/GetFaqsQuery.php @@ -0,0 +1,35 @@ +> + */ +final readonly class GetFaqsQuery implements Query +{ + /** + * @return \Illuminate\Support\Collection + */ + public function __invoke(QueryInput $input): Collection + { + Assert::isAOf( + $input, + QueryInputEmpty::class, + ); + + return Faq::query() + ->orderBy('order', 'asc') + ->get() + ->map(fn (Faq $faq): FaqDto => FaqDto::fromModel($faq)); + } +} diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 36c35d23..621b6a8f 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -4,34 +4,29 @@ declare(strict_types=1); namespace App\Services; -use App\Contracts\Directories\OrderDirectory; use App\Dto\OrderDto; use App\Models\Customer; use App\Models\Order; -use Domain\Models\ValueObjects\Pagination; -use Illuminate\Contracts\Pagination\LengthAwarePaginator; -use Ramsey\Uuid\Uuid; +use Domain\Models\ValueObjects\Matricule; class OrderService { - public function __construct( - private readonly OrderDirectory $orderDirectory - ) { - } - - /** @return \Illuminate\Pagination\LengthAwarePaginator */ - public function paginateOrdersFor(Customer $customer, Pagination $pagination): LengthAwarePaginator - { - return $this->orderDirectory->getPaginatedOrdersOf( - $customer, - $pagination, - true - ); - } - public function isOrderOwnedBy(Order | OrderDto $order, Customer $customer): bool { - return $this->orderDirectory - ->findOf($customer, Uuid::fromString((string) $order->id)) !== null; + /** @var \Domain\Models\ValueObjects\Matricule|string|null $employeeMatricule */ + $employeeMatricule = $customer->employee()->value('matricule'); + + if ($employeeMatricule === null) { + return false; + } + + $matriculeValue = $employeeMatricule instanceof Matricule + ? $employeeMatricule->value + : (string) $employeeMatricule; + + return Order::query() + ->where('id', (string) $order->id) + ->where('employee_matricule', $matriculeValue) + ->exists(); } } diff --git a/tests/Integration/WithApp/App/Queries/Customers/GetCustomerByEmailQueryTest.php b/tests/Integration/WithApp/App/Queries/Customers/GetCustomerByEmailQueryTest.php new file mode 100644 index 00000000..7e41426a --- /dev/null +++ b/tests/Integration/WithApp/App/Queries/Customers/GetCustomerByEmailQueryTest.php @@ -0,0 +1,47 @@ + $email]); + $customer->hashcode = new CrmHashcode(Uuid::uuid4()); + $customer->save(); + + $query = app(GetCustomerByEmailQuery::class); + $input = new GetCustomerByEmailQueryInput($email); + + // WHEN + $result = $query($input); + + // THEN + expect($result)->toBeInstanceOf(ShopperId::class) + ->and($result->value->toString())->toBe($customer->id); + }); + + it('returns null when customer with email does not exist', function (): void { + // GIVEN + $email = new Email('nonexistent@example.com'); + $query = app(GetCustomerByEmailQuery::class); + $input = new GetCustomerByEmailQueryInput($email); + + // WHEN + $result = $query($input); + + // THEN + expect($result)->toBeNull(); + }); +}); diff --git a/tests/Integration/WithApp/App/Queries/Faqs/GetFaqsQueryTest.php b/tests/Integration/WithApp/App/Queries/Faqs/GetFaqsQueryTest.php new file mode 100644 index 00000000..65273798 --- /dev/null +++ b/tests/Integration/WithApp/App/Queries/Faqs/GetFaqsQueryTest.php @@ -0,0 +1,41 @@ +question = 'Second question?'; + $faq2->answer = 'Second answer.'; + $faq2->order = 2; + $faq2->save(); + + $faq1 = new Faq(); + $faq1->question = 'First question?'; + $faq1->answer = 'First answer.'; + $faq1->order = 1; + $faq1->save(); + + $query = app(GetFaqsQuery::class); + + // WHEN + $faqs = $query(new QueryInputEmpty()); + + // THEN + expect($faqs)->toBeInstanceOf(Collection::class) + ->and($faqs)->toHaveCount(2) + ->and($faqs->first())->toBeInstanceOf(FaqDto::class) + ->and($faqs->first()->question)->toBe('First question?') + ->and($faqs->last()->question)->toBe('Second question?'); + }); +});