Reputation: 1101
i have project on laravel 5.3 and this is my function inside the controller
public function CustomerReportGet(Request $request)
{
$full = Voucherreceive::where('voucherreceive_customer_id','=',$request->customer_id)->sum('voucherreceive_amount');
if($request->from_date == '' and $request->to_date == '')
$data = Voucherreceive::where('voucherreceive_customer_id','=',$request->customer_id)->get();
elseif($request->from_date <> '' or $request->to_date <> '')
{
$data = Voucherreceive::where('voucherreceive_customer_id','=',$request->customer_id)->
whereBetween('created_at',array($request->from_date,$request->to_date));
}
return $data;
}
how can i send the $full variable with $data .. i tried to do this
$data = Voucherreceive::where('voucherreceive_customer_id','=',$request->customer_id)->with('full')->get();
but i still have internal server error .. thanks
Upvotes: 0
Views: 86
Reputation: 1438
Before return, you can make an array with full & data as it's element and then return this new array.
return array($full, $data);
Or you can define the relationship in the model to use 'with'
Upvotes: 2