23 lines
506 B
PHP
23 lines
506 B
PHP
<?php
|
|
|
|
namespace App\Actions\Page;
|
|
|
|
use App\DTOs\PageData;
|
|
use App\Events\ModelChanged;
|
|
use App\Models\Page;
|
|
use App\Repositories\Contracts\PageRepositoryInterface;
|
|
|
|
final class UpdatePageAction
|
|
{
|
|
public function __construct(private PageRepositoryInterface $repository) {}
|
|
|
|
public function execute(Page $page, PageData $data): Page
|
|
{
|
|
$result = $this->repository->update($page, $data->toArray());
|
|
|
|
ModelChanged::dispatch(Page::class, 'updated');
|
|
|
|
return $result;
|
|
}
|
|
}
|