<?php

namespace App\Actions\User;

use App\Events\ModelChanged;
use App\Models\User;
use App\Repositories\Contracts\UserRepositoryInterface;

class DeleteUserAction
{
    public function __construct(private UserRepositoryInterface $repository) {}

    public function execute(User $user): bool
    {
        $this->repository->delete($user);

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

        return true;
    }
}
