laravel where function code example

Example 1: where like laravel

User::query()
   ->where('name', 'LIKE', "%{$searchTerm}%") 
   ->orWhere('email', 'LIKE', "%{$searchTerm}%") 
   ->get();

reference:
https://freek.dev/1182-searching-models-using-a-where-like-query-in-laravel

Example 2: laravel where like

$users = DB::table('users')
                ->where('name', 'like', 'T%')
                ->get();

Example 3: laravel update from query

$affected = DB::table('users')
              ->where('id', 1)
              ->update(['votes' => 1]);

Example 4: laravel orWhere

$camps = $field->camps()->where('status', 0)->where(function ($q) {
    $q->where('sex', Auth::user()->sex)->orWhere('sex', 0);
})->get();