25 lines
558 B
PHP
25 lines
558 B
PHP
<?php
|
|
|
|
namespace App\Actions\Comment;
|
|
|
|
use App\Events\ModelChanged;
|
|
use App\Models\Comment;
|
|
use App\Repositories\Contracts\CommentRepositoryInterface;
|
|
|
|
final class UpdateCommentAction
|
|
{
|
|
public function __construct(private CommentRepositoryInterface $repository) {}
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
*/
|
|
public function execute(Comment $comment, array $data): Comment
|
|
{
|
|
$result = $this->repository->update($comment, $data);
|
|
|
|
ModelChanged::dispatch(Comment::class, 'updated');
|
|
|
|
return $result;
|
|
}
|
|
}
|