whereNotIn();
Using whereNotIn() Method
For example, if you want to query all Posts where the ID is not 10, 11, 12, and 13 you can write your code as follows.
<?php Post::query()->whereNotIn('id', [10, 11, 12, 13])->get();
Using where Method
Or an alternative to that is to use the normal "where" clause and then have the condition as follows.
<?php Post::query()->where('id', '!=' , 10)->orWhere('id', '!=' , 11)->orWhere('id', '!=' , 12)->orWhere('id', '!=' , 13)->get();
Leave a reply