When I am indexing models, I'm storing both the name and client ID.
[
'name' => 'Test',
'client_id' => 3
]
So I'd like to be able to search for my model that has the name test, with the client_id of 3 without even having to hit the database. I've tried the following -
$results = Company
::search('test')
->where('client_id', 3)
->take(10)->get();
$company = new Company;
$company = $company->where('client_id', 3);
$results = Company
::search('test')
->constrain($company)
->take(10)->get();
Now - the great thing is that both the above methods work and return results. The problem I am facing is that I want to check for the presence of the correct client_id property without ever hitting the MySQL database at all. However, every time I run either of the above methods, it doesn't take into consideration the client_id constraint and passes any match for test, regardless of the client_id. Am I doing something wrong, is there a way to achieve this, or is it entirely impossible?
Hi,
When I am indexing models, I'm storing both the name and client ID.
So I'd like to be able to search for my model that has the name test, with the client_id of 3 without even having to hit the database. I've tried the following -
Now - the great thing is that both the above methods work and return results. The problem I am facing is that I want to check for the presence of the correct client_id property without ever hitting the MySQL database at all. However, every time I run either of the above methods, it doesn't take into consideration the
client_id
constraint and passes any match fortest
, regardless of the client_id. Am I doing something wrong, is there a way to achieve this, or is it entirely impossible?Thanks!