Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Merging Two Laravel Collections keeping the original keys

$material_grp1 = Batch::findOrFail($batch_id)->batchdetails->mapWithKeys(function($item)  {                
            return [
                $item->material_id => $item
            ];
        });;
         $material_grp2 = Batch::with('productoutput.productoutputdetails.packsizes')
                            ->find($batch_id)->productoutput->productoutputdetails
                            ->mapWithKeys(function($item)  {                
            return [
                $item->packsizes->material_id => $item
            ];
        });
         $material_grp = $material_grp1->union($material_grp2);
Comment

PREVIOUS NEXT
Code Example
Php :: header in fpdi 
Php :: upload image to mysqli database 
Php :: php leggere file txt riga per riga 
Php :: php array form 
Php :: placeholder for select php 
Php :: cara looping abjad with range no kapital 
Php :: wherenotnull laravel 
Php :: $e = array("red", "green", "blue"); echo intval($e) . "<br"; 
Php :: put_assoc 
Php :: export laravel path fedora 
Php :: laravel collection zip 
Php :: csv import laravel 
Php :: php slots 
Php :: wp wc php use comma separated thousands 
Php :: breaks the collection into multiple smaller collections Laravel 
Php :: limit query laravel 
Php :: install php 7.4 amazon linux 2 
Php :: eventon php code 
Php :: Laravel You may determine if a template inheritance section has content using the @hasSection directive: 
Php :: php is multiple of 
Php :: php array key value print 
Php :: PHP strpbrk — Search a string for any of a set of characters 
Php :: list custom post in wp 
Php :: php When I try to run my code in chrome, i see the code that I have made in phpstorm and not the function that it has to do 
Php :: small echo php 
Php :: To enqueue css & js quickly 
Php :: hide my echo from page php 
Php :: convert a value to a float in php 
Php :: launch new tab and refresh original page codeigniter 
Php :: standalone laravel orm 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =