I am having a difficulty accessing the array with json values in it. The values came from another table where I have established a relationship with another table. However, I cannot figure out how to access it correctly. Here is my code.
Model relationship between product and inventory.
Product
public function inventory(){
return $this->hasMany('App\InventoryRecord\InventoryRecord');
}
Inventory
public function products(){
return $this->belongsTo('App\Product\Product','product_id');
}
View
@foreach($products as $val)
<?php //$quantity[$i++] = $val->id; ?>
<tr class="tbl-prod-row">
<td><input type='checkbox' style='width:30px; height:20px;' class='radio_check_all prod-id-checkbox' id='radio_check_all prod-id-checkbox' value="{{ $val->id }}"></td>
<td style="display:none;">{{ $val->id }}</td>
<td style="display:none;">{{ $val->category }}</td>
<td>{{ $val->pharmaceutical }}</td>
<td>{{ $val->description }}</td>
<td>{{ $val->type }}</td>
<td>{{ $val->unit }}</td>
<td>{{ $val->price }}</td>
<td>{{ $val->created_at }}</td>
<td>{{ $val->po_status }}</td>
<td>{{ $val->inventory }}</td>
</tr>
@endforeach
There is no error shown here but everytime I wanted to access some values in the array by changing the $val->inventory to $val->inventory->quantity, it return an error.
Please help me with this. Thanks a lot.

