Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

w1lldone's avatar

What is the best way to protect destroy method in Controller?

I'm working on API project. I have Proceeding model that has published_at attribute and it has hasMany relationship with Article model. A proceeding record may be trashed when it hasn't published yet. What is the best way to check if the proceeding is not published yet? Is it Validation, Middleware, or Authorization? If someone try to delete or update an article on a published proceeding, an exception should be thrown.

0 likes
6 replies
w1lldone's avatar

@martinbean Thanks for your answer. The API should response with 403 Forbidden if the authorization fails, right?

Please or to participate in this conversation.