How can I prepare the following query in laravel?
SELECT u.*
FROM `users` AS u
INNER JOIN `roles_users` AS r
ON u.id = r.user_id
WHERE r.role_id = ".Role::USER_CLIENT_COACH."
Any help will be appreciated!
Try using the query builder like so:
DB::table('users')
->join('roles_users', 'users.id', '=', 'roles_users.user_id')
->select('users.id')
->where('roles_users.role_id' = Role::USER_CLIENT_COACH)
->get();
Wrote this very quickly so check the syntax, but generally this should point you in the right direction.