Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
39 lines
1,004 B
PHP
39 lines
1,004 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Cqs\Actions\Settings;
|
|
|
|
use App\Contracts\Action;
|
|
use App\Contracts\ActionInput;
|
|
use App\Models\Setting;
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
|
use Webmozart\Assert\Assert;
|
|
|
|
/**
|
|
* @implements \App\Contracts\Action<\App\Cqs\Actions\Settings\UpdateSettingsInput, \App\Models\Setting>
|
|
*/
|
|
final class UpdateSettings implements Action
|
|
{
|
|
/**
|
|
* @param \App\Cqs\Actions\Settings\UpdateSettingsInput $input
|
|
*/
|
|
#[\Override]
|
|
public function __invoke(ActionInput $input): Setting
|
|
{
|
|
Assert::isInstanceOf($input, UpdateSettingsInput::class);
|
|
|
|
$setting = Setting::getSingleton();
|
|
$setting->fill([
|
|
'employee_sites' => array_values(
|
|
array_map(
|
|
static fn (ShopperSiteCode $siteCode): string => $siteCode->value,
|
|
$input->employeeSites
|
|
)
|
|
),
|
|
]);
|
|
$setting->saveOrFail();
|
|
|
|
return $setting;
|
|
}
|
|
}
|