How to alter data in relations field in laravel eloquent model after returning result?

158 Views Asked by At

I'm working with Laravel 5.6. And fetching data from database using Eloquent model. On that returned result set I found "relations" field as empty. But I need to alter this "relations" filed with some custom data. How should I do that?

My returned result:

enter image description here

In the picture, highlighted filed need to alter with some custom data.

1

There are 1 best solutions below

0
leaveme_alone On

Yes, I solved the above problem myself. Solution like below:

$combinations_obj = (object) array("requested_quantity" => $product_combination->product_combination[0]->requested_quantity);
$combination_data->combinations[] = $combinations_obj;
$product_challan_infos->product_combination_list[] = $combination_data;