Answers for "laravel where function"

PHP
5

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
Posted by: Guest on December-19-2020
10

laravel update from query

$affected = DB::table('users')
              ->where('id', 1)
              ->update(['votes' => 1]);
Posted by: Guest on May-07-2020
6

laravel orWhere

$camps = $field->camps()->where('status', 0)->where(function ($q) {
    $q->where('sex', Auth::user()->sex)->orWhere('sex', 0);
})->get();
Posted by: Guest on October-20-2020
8

laravel where like

$users = DB::table('users')
                ->where('name', 'like', 'T%')
                ->get();
Posted by: Guest on May-13-2020
0

where in laravel

$users = Users::whereIn('id', array(1, 2, 3))->get()
Posted by: Guest on July-27-2021
0

laravel where in

$users = DB::table('users')->whereIn('id', array(1, 2, 3))->get()
Posted by: Guest on June-24-2021

Browse Popular Code Answers by Language