I have a users
table and follows
table and two models for both. I have user left join to fetch the data from the table, but I am confused to use which model and join table (i.e).
$user = Follows::select( 'users.id', 'users.username', 'users.photo' )
->leftJoin('users', 'follows.fk_users_id', '=', 'users.id')
->where('follows.follower_users_id' ,'=', $id)
->get();
or
$user = Users::select( 'users.id', 'users.username', 'users.photo' )
->leftJoin('follows', 'follows.fk_users_id', '=', 'users.id')
->where('follows.follower_users_id' ,'=', $id)
->get();
I am coding this in Follows model But I only need data from users
table where it meets the condition with follows
table, need your help as I am new to laravel.
My question is whether to use Follows model and left join users table or use Users model and left join follows table