Laravel Query Builder Where Exists Example (ok)
https://www.itsolutionstuff.com/post/laravel-5-query-builder-where-exists-exampleexample.html
Laravel Query Builder Where Exists Example
SELECT *FROM `items`WHERE EXISTS (SELECT `items_city`.`id` FROM `items_city` WHERE items_city.item_id = items.id)DB::table('items') ->whereExists(function ($query) { $query->select("items_city.id") ->from('items_city') ->whereRaw('items_city.item_id = items.id'); }) ->get();<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', [HomeController::class, 'index'])->name('home');
Route::get('/test', [HomeController::class, 'test'])->name('test');PreviousLaravel Like Query Example using Eloquent Where Clause (ok)NextLaravel orWhere Condition using Eloquent Query
Last updated