Answers for "laravel intersect query"

PHP
0

laravel collection intersect

$collection = collect(['Desk', 'Sofa', 'Chair']);

$intersect = $collection->intersect(['Desk', 'Chair', 'Bookcase']);

$intersect->all();

// [0 => 'Desk', 2 => 'Chair']
Posted by: Guest on July-24-2021
0

how to use union and intersection in laravel query

$queryWithParent = SaleService::query()
    ->select(DB::raw('DISTINCT ON (properties.parent_id) sale_services.*'))
    ->from('sale_services')
    ->join('properties', 'sale_services.property_id', '=', 'properties.id')
    ->whereNotNull('properties.parent_id')
    ->orderBy('properties.parent_id')
    ->orderBy('sale_services.index_range', 'desc');

$queryWithoutParent = SaleService::query()
    ->select(DB::raw('sale_services.*'))
    ->join('properties', 'sale_services.property_id', '=', 'properties.id')
    ->whereNull('properties.parent_id');

$query = $queryWithParent->union($queryWithoutParent);
Posted by: Guest on July-23-2020
0

laravel collection intersect

use AppModelsUser;

$users = $users->intersect(User::whereIn('id', [1, 2, 3])->get());
Posted by: Guest on December-01-2020

Browse Popular Code Answers by Language