public function teachers()
{
return $this->hasMany(User::class)->where('teacher',1);
}
or similar.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys I want to put all my different users (teachers, students, admins) in the same table but how can I differentiate between them when I add the relationships in this table. For example : the teachers belongs to a departement table, and the students belongs to another table which is faculty table ! The problem is when I add those relationships to the users table it will add automatically to all types of users (teachers, students, admins...).
Please or to participate in this conversation.