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

mkdesign82's avatar

Create Model which related to column name

hi, sorry for wrong title. I have a users table which it contains 3 type of users [teachers, managers , students]. what I need to do is to create , 3 model classes above names. when i need each of them, the model should first select the specific type then do the reset of the operation . like if i wanted to select all students from users table . i think it should be something like Student::get(); do you guys have any idea how is that gonna work for me ? thank you for any help .

0 likes
3 replies
ohffs's avatar
ohffs
Best Answer
Level 50

You could also (maybe) use a global scope. So each model references the same table but use the scope to do something like where('account_type', 'student').

1 like
mkdesign82's avatar

ohffs thank you for the answer , I did know about scopes , but i haven't registers any global scope for any specific model . thank you for the answer .

Please or to participate in this conversation.