0

I'm using the laravelista comments package to make comments for my site.

When trying to create a comment, the POST method goes through (with the commentable model and its id properly referenced), but the comment is not being saved.

I know the corresponding store method is being called as it redirects properly and appends #comment to the url, but the id() of the comment isn't there:

vendor\laravelista\comments\src\CommentController.php (69 - 71)

        $comment->save();

        return Redirect::to(URL::previous() . '#comment-' . $comment->getKey());

But the redirect url looks like:

http://127.0.0.1:8000/test#comment-

So, I error_log($comment) above the line that calls save(), and get this in the terminal:

{"commenter_id":1,
"commenter_type":"App\\Models\\User",
"commentable_id":25,
"commentable_type":"App\\Models\\Discussion", 
"comment":"test comment",
"approved":true,
"commenter":{"id":1,"name":"a", [other columns in user model]},
"commentable":{"id":25, [other columns in this model]}}

So, the model instance is definitely being created but the save() function isn't working.

When I

error_log($comment->save());

It returns a 1, indicating success

I try to replicate it in tinker:

>>> use Laravelista\Comments\Comment;
>>> $comment = new Comment;
=> Laravelista\Comments\Comment {#3585}
>>> $comment->comment = "tinker";
=> "tinker"
>>> echo($comment);
{"comment":"tinker"}⏎
>>> $comment->save();
=> true
>>>

But nothing in the DB either time.

If anyone is able to point me in the right direction it would be greatly appreciated.

0 Answers0