<?php

namespace App\Actions\Announcement;

use App\Events\ModelChanged;
use App\Models\Announcement;
use App\Repositories\Contracts\AnnouncementRepositoryInterface;

final class DeleteAnnouncementAction
{
    public function __construct(private AnnouncementRepositoryInterface $repository) {}

    public function execute(Announcement $announcement): bool
    {
        $this->repository->delete($announcement);

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

        return true;
    }
}
