i have facing a problem at laravel.
I want to replicate/clone of collection after apply filter the collection.
code is below:
/* Scope function */
$plansFilterIndexes=Plans::PlansFilterFields();
$planFilters=Plans::FilterFieldsSerial($query);
/* Create Plans collection */
$PlansAll=Plans::all();
/* Plans Filter by url
* here checking $planFilter indexes IS AVALIABLE AT
* DEFINED INDEX $plansFilterIndexes
*/
$query = null;
foreach($planFilters as $eachIndexKey => $eachIndexValue):
echo $eachIndexKey.'------'.$eachIndexValue.'<br/>';
if(array_search($eachIndexKey, $plansFilterIndexes) != false):
$PlansAll = $PlansAll->where($eachIndexKey, $eachIndexValue);
endif;
endforeach;
//dd($PlansAll);
/* Clone collection into new once for copy */
$PlansAllClone =$PlansAll->replicate();
dd($PlansAllClone);
Try with Clone an Eloquent object including all relationships? solution but did not get result
Show error: Method replicate does not exist.
It not working.
Question:
Why $PlansAllClone =$PlansAll->replicate(); is failed to give result. and if it not possiable ,show i will achieve it.