Skip to content
This repository has been 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

Closed
aalaap opened this issue Nov 14, 2018 · 0 comments
Closed

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

aalaap opened this issue Nov 14, 2018 · 0 comments
Assignees

Comments

@aalaap
Copy link
Contributor

aalaap commented Nov 14, 2018

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.

@actuallymab actuallymab self-assigned this Nov 29, 2018
actuallymab added a commit that referenced this issue Jan 4, 2019
fixes #43 - Returning comment object after comment operation
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants