To exclude users with the "super-admin" role in a query using Eloquent in Laravel, you can use the whereDoesntHave method. This method allows you to filter out records that have a certain relationship. In your case, you want to exclude users who have a role with the auth_code of "super-admin".
Here's how you can achieve this:
$users = User::whereDoesntHave('role', function ($query) {
$query->where('auth_code', 'super-admin');
})->get();
In this example, role is the relationship method defined in your User model that relates to the Role model. The whereDoesntHave method will exclude any users that have a role with the auth_code of "super-admin".
Make sure that your User model has a relationship defined like this:
public function role()
{
return $this->belongsTo(Role::class);
}
This setup will ensure that your query correctly excludes users with the "super-admin" role.