for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Services;
use App\Http\Requests\CommentStoreRequest;
use App\Models\Comment;
class CommentService
{
/**
* Create a comment
*
* @param \App\Http\Requests\CommentStoreRequest $data
* @param mixed $entity
* @return \App\Models\Comment
*/
public function createComment(CommentStoreRequest $data, object $entity): Comment
$comment = new Comment();
$comment->body = $data['body'];
$comment->name = $data['name'];
$comment->email = $data['email'];
$entity->comments()->save($comment);
//then publish comment
return $comment;
}