Wednesday, March 29, 2017

How to Merge or Combine return data from model in Controller Laravel

I have 3 function, it is a() b() and c()

and then, function a() returned :

{
    id    =>
    total1 =>
}

function b() returned like funcion a() too, but have a different value (total1 and total2)

function c() returned :

{
    id   => //same value just like function a or b
    name =>
}

 

$a = $model->a(); // from function a();
$b = $model->b(); // from function b();
$c = $model->c(); // from function c();

i want combine that 3 returned values into array like this :

array = ['id','name', 'total1', 'total2']

any idea ? Thanks



via DarkCode999

Advertisement