Where Not Like not functioning laravel DB Eloquent.
```
$data->where(function ($query) {
$query->where('sample1', 'not LIKE', '%not%')
->orWhere('sample2', 'not LIKE', '%not%');
});
```
try reformatting please. add your three backticks on a new line and then your code underneath it.
dont know how tried to search but failed.
Use the preview slider to make sure the code is readable before submitting.
$data->where(function ($query) { $query->where('sample1', 'not LIKE', '%not%') ->orWhere('sample2', 'not LIKE', '%not%');
});
@elgetenz so what's not working with
$data->where(function ($query) {
$query->where('sample1', 'not LIKE', '%not%')
->orWhere('sample2', 'not LIKE', '%not%');
});
?
show your failing test
@elgetenz I know this is an old post so for the benefit for others, if using MySQL and the field is null, then the NOT LIKE operator won't work. So maybe try...:
$data->where(function ($query) {
$query->where('sample1', 'not LIKE', '%not%')
->orWhere('sample2', 'not LIKE', '%not%')
->orWhereNull('sample1')
->orWhereNull('sample2');
});
Please sign in or create an account to participate in this conversation.