I have been trying to connect my web app to BaaS, called app42-apphq.shephertz.com
Is there a guide on how to do it? I have tried to read the documentation and I have connected, but the problem is displaying the json response to my view, because the response is looped through two arrays.
This is my controller function
$storageService = App42API::buildStorageService();
$inventory = $storageService->findAllDocuments($dbName,$collectionName);
$jsonDocList = $inventory->getJsonDocList();
foreach( $jsonDocList as $jsonDoc )
{
$products = json_decode($jsonDoc->getJsonDoc());
for($i=0;$i<=count($products);$i++)
{
print($products->productDescription);
print($products->productName);
print($products->productPrice);
}
}
And this is my view
@extends('templates.home.another')
@section('content')
<div class="container" style="margin-left:270px; width:70%; margin- top:60px;">
<div class="col-lg-8">
<table id="app42sales" class=" table table-striped" >
<thead>
<tr>
<th>ID</th>
<th>Transaction Type</th>
<th>Number of items</th>
<th>Total Cost</th>
<th>Week of year</th>
<th>Year</th>
<th>Date</th>
<th>Date of year</th>
</tr>
</thead>
<tbody>
@foreach($jsonDoc as $doc)
{
@foreach($records as $record)
<?php $i = 1; ?>
<tr>
<td>{{ $i }}</td>
<td>{{ $record->transactionType }}</td>
<td>{{ $record->numberOfItems }}</td>
<td>{{ $record->totalCost }}</td>
<td>{{ $record->weekOfYear }}</td>
<td>{{ $record->year }}</td>
<td>{{ $record->date }}</td>
<td>{{ $record->dayOfYear }}</td>
</tr>
<?php $i++ ;?>
@endforeach
}
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
I hope this may help you
Controller
View