What did you do?
I would set the user_id on the post and then do something like $post->user_id === auth()->id()
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Let's say my User can make blog posts. I have now retrieved a blog post and I want check if the given blog post belongs to the authenticated user so it can be edited. I was able to accomplish that but it doesn't seem the best way to do it.
Please or to participate in this conversation.