Example 1: laravel not in query
DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();
Example 2: laravel orWhere
$camps = $field->camps()->where('status', 0)->where(function ($q) { $q->where('sex', Auth::user()->sex)->orWhere('sex', 0); })->get();
Example 3: AND-OR-AND + brackets with Eloquent
//mysql query be like this // ... WHERE (gender = 'Male' and age >= 18) or (gender = 'Female' and age >= 65) //Eloquent query is // ... $q->where(function ($query) { $query->where('gender', 'Male') ->where('age', '>=', 18); })->orWhere(function($query) { $query->where('gender', 'Female') ->where('age', '>=', 65); }) //@sujay
Example 4: snactum laravel
composer require laravel/sanctum
Example 5: laravel where and where
Table::where('Column', Value)->where('NewColumn', Value)->get();
Comments
Post a Comment