You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.
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.
The text was updated successfully, but these errors were encountered:
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 calledcommentAndReturn()
which does the same thing ascomment()
but returns theComment
model instead ofUser
. It would be nice to have a more eloquent alternative.The text was updated successfully, but these errors were encountered: