Closed eokorieFA closed 5 years ago
Hey! Appreciate the positive feedback!!
So, that method will be called in UserFilter
before queries to the privacySettings
relation are applied from either the $relations
array or the relation
filter method which means if there are no queries to that relation the setup method will not be called.
If you are trying to apply this by default without any queries to that relation that could explain why it's not working.
One trick to ensure that's called regardless of input would be to call the relation
method in a setup method on the user filter with an empty closure to ensure that relation is always setup.
public function setUp()
{
$this->relation ('privacySettings', function() {});
}
Awesome stuff.. I have managed to get it working with this:
public function setUp() {
$this->related('privacySettings', static function ($query) {
$query->where('key', '=', 'show_in_search_results')->where('value', '=', 1);
});
}
And it is working as expected... Thanks for putting me on the right path and once again... great package 👍
First of all, fantastic package. I have been using this for a good while and it has made life so much easier when building a search functionality into my app. However I am having an when trying to filter records via a relation.
Take the following:. I am trying to create a user search functionality and trying to add an option where the users records can be displayed in the search results based on their privacy setting. I am however finding that the privacySettingsSetup is not being triggers therefore the results always come back the same.
Is there something that I am missing here to get this to work the way I would like it to?
Thanks in advance,
Emmanuel