Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

How to reuse parts of Eloquent builder in Laravel

$shared = TableA::join('tableb', 'tablea.bid', '=', tableb.id)
           ->join('talbec', 'tableb.cid', '=', tablec.id)
           ->join('tabled', 'tablec.did', '=', tabled.id);

$a = $shared->clone()->where('tablea_col', '=', true)->get();

$b = shared->clone()->where('tableb_col', '=', true)->get();
before Laravel 8, use

$a = clone $shared;
$b = clone $shared;
$a = $a->where('tablea_col', '=', true)->get();
$b = $b->where('tableb_col', '=', true)->get();
Comment

PREVIOUS NEXT
Code Example
Typescript :: site:community.nxp.com dts gpio output high active 
Typescript :: typescript isvalidguid 
Typescript :: vim remove surrounding brackets with surround plugin 
Typescript :: facts about poutine 
Typescript :: how to delete a struct in a arra of strcts c 
Typescript :: Lua programming - setting up physics 
Typescript :: can subclass method infere exceptions of its superclass method 
Typescript :: difference known_hosts authorized_keys 
Typescript :: typescript map interface 
Typescript :: how to get all arrangments python 
Typescript :: box collision detection 
Typescript :: how to populate array in typescript 
Typescript :: check if a user already exists firebase realtime database react native 
Typescript :: There are 7 components with misconfigured ETags 
Typescript :: how to exclude certain proprty from a class typescript 
Typescript :: which of the following object types below cannot be replicated 
Typescript :: how to compile in typescript 
Typescript :: how to remove dots in unordered list html 
Typescript :: endurance testing 
Typescript :: split a column of lists pandas 
Typescript :: print diagonal elements of matrix in c 
Typescript :: unity destroy all objects with tag 
Cpp :: dart async function 
Cpp :: excel vba delete worksheet if exists 
Cpp :: remove or erase first and last character of string c++ 
Cpp :: how to print a decimal number upto 6 places of decimal in c++ 
Cpp :: colourful text in c++ 
Cpp :: qt remove resize handle 
Cpp :: Tech mahindra coding questions 
Cpp :: insert at position in vector c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =