23 lines
487 B
PHP
23 lines
487 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 CreatePageAction
|
|
{
|
|
public function __construct(private PageRepositoryInterface $repository) {}
|
|
|
|
public function execute(PageData $data): Page
|
|
{
|
|
$result = $this->repository->create($data->toArray());
|
|
|
|
ModelChanged::dispatch(Page::class, 'created');
|
|
|
|
return $result;
|
|
}
|
|
}
|