Laravel Eloquent - How to query NOT LIKE?

There are a few different options depending on your needs. You can use any of the following to find something that is not like a certain string:

Users::where('username', 'not like', "%ray%")->get();

DB::table('users')->where('username', 'not like', '%ray%');

Capsule::table('users')->select('*')->where('username', 'not like', '%ray%')->get();


Use DB facade

   $data = DB::table('users')->select('*')->where('username', 'not like', '%ray%')->get();

Also you can use

 $data = User::where('username', 'not like', "%ray%")->get();

Simply you can use the model to get that result

User::where('username', 'not like', "%ray%")->get();