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

Dev0ps's avatar

Creating multiple model is secure

I am very bad in database relationship so I create model for every migration it is secure or not. if it is not secure then how I can make them secure

0 likes
4 replies
tykus's avatar

No idea what you're talking about here. You're going to have to explain yourself.

2 likes
Vilfago's avatar

I cannot see any security issue with just that... But as @tykus said, your question is not clear.

Dev0ps's avatar

I mean, I create model for every table or migration. so my question is that it is secure of having model for every migration or not

Cronix's avatar

Each table should have a model, except for many to many relationships. You wouldn't have a model for the intermediary lookup table.

Like if you have users, roles, and role_user tables so a user can have many roles, you would just have a model for User and Role and a belongsToMany relationship in the User model for the Role. Laravel will use the role_user table automatically so don't need a model for that.

And I'm really not sure what you mean by "secure". Define that. Secure how? How would it be insecure? What is your concern?

Just having models by themselves pose no actual security issues. It's how you use them that may be secure/insecure.

Please or to participate in this conversation.