Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

How do I get the comment object after it has been created? #43

@aalaap

Description

@aalaap

The standard way, i.e. $user->comment($post, 'Lorem ipsum...') returns the $user object itself. Is there any way to get the comment object that was just created? It wouldn't be wise to manually look through the $post->comments collection for this.

Perhaps a facade could help. Something like LaravelComment::comment($user, $comment, ...)?

At the moment, I've extended the CanComment trait with my own method called commentAndReturn() which does the same thing as comment() but returns the Comment model instead of User. It would be nice to have a more eloquent alternative.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions