<?php

namespace App\Actions\Page;

use App\Events\ModelChanged;
use App\Models\Page;
use App\Repositories\Contracts\PageRepositoryInterface;

final class DeletePageAction
{
    public function __construct(private PageRepositoryInterface $repository) {}

    public function execute(Page $page): bool
    {
        $this->repository->delete($page);

        ModelChanged::dispatch(Page::class, 'deleted');

        return true;
    }
}
