If there is no relationship; why is the Lesson model responsible for loading User instances? What problem are you actually trying to solve here?
Aug 28, 2024
5
Level 1
How can I load non-related model as relationship ?
Hello all. I have a User and Lesson models. these models are not related to each other.
users table: id, username, password, is_active lessons table: id, title
User
class User extends Modle
{
// code
}
Lesson
class Lessosn extends Modle
{
public function users()
{
// I need to return all users here where is_active=true as RELATIONSHIP
// return User::where('is_active', true);
}
}
In the Lesson model I want to have a relationship to load users where (is_active, true) So I can list all users where is_active = true
Thanks
Please or to participate in this conversation.