Small examples
Let's start with a basic scenario, A tenant has N users, each user has a config and a profile:
Bring all users wich have:
user column is_active in config relationship equals true
user column address in profile relationship contains “Foo”
user column tenant_id equals 1
Pure Eloquent:
User::where('tenant_id', 1)
->whereHas('profile', function($q) {
$q->whereRaw('address LIKE %Foo%')
})
->whereHas('config', function($q) {
$q->where('is_active', true);
});
Eloquent Search:
User::search('profile.address', 'contains', "Foo")-search('config.is_active', true)->search('tenant_id', 1)
Bring a list of user pictures, from a specific tenant, following the conditions:
user column is_active in config equals false
user column created_at must be greater than equal 2000–01–01 or null
Picture is a column in profile…