Skip to content
Snippets Groups Projects
EpisodeController.php 36.5 KiB
Newer Older
  • Learn to ignore specific revisions
  •         $validData = $this->validator->getValidated();
    
            $newComment = new EpisodeComment([
    
                'actor_id'   => interact_as_actor_id(),
    
                '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());
            }
    
    
            $validData = $this->validator->getValidated();
    
    
            $newReply = new EpisodeComment([
    
                'actor_id'       => interact_as_actor_id(),
                'episode_id'     => $this->episode->id,
    
                '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();
        }