Newer
Older
}

Yassine Doghri
committed
$validData = $this->validator->getValidated();
$newComment = new EpisodeComment([
'actor_id' => interact_as_actor_id(),
'episode_id' => $this->episode->id,

Yassine Doghri
committed
'message' => $validData['message'],
'created_at' => new Time('now'),
'created_by' => user_id(),
]);
$commentModel = new EpisodeCommentModel();
if (
! $commentModel->addComment($newComment, true)
) {
return redirect()
->back()
->withInput()
->with('errors', $commentModel->errors());
}
// Comment has been successfully created
return redirect()->back();
}
public function attemptCommentReply(string $commentId): RedirectResponse
{
$rules = [
'message' => 'required|max_length[500]',
];
if (! $this->validate($rules)) {
return redirect()
->back()
->withInput()
->with('errors', $this->validator->getErrors());
}

Yassine Doghri
committed
$validData = $this->validator->getValidated();
$newReply = new EpisodeComment([
'actor_id' => interact_as_actor_id(),
'episode_id' => $this->episode->id,

Yassine Doghri
committed
'message' => $validData['message'],
'in_reply_to_id' => $commentId,
'created_at' => new Time('now'),
'created_by' => user_id(),
]);
$commentModel = new EpisodeCommentModel();
if (
! $commentModel->addComment($newReply, true)
) {
return redirect()
->back()
->withInput()
->with('errors', $commentModel->errors());
}
// Reply has been successfully created
return redirect()->back();
}