我一直在尝试将我的网络应用程序连接到BaaS,名为app42-apphq.shephertz.com
是否有关于如何操作的指南?我已经尝试阅读文档并且已经连接,但是问题是在我的视图中显示json响应,因为响应是通过两个数组循环的。
这是我的控制器功能
$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);
}
}
这是我的观点
@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
答案 0 :(得分:1)
我希望这可以帮到你
控制器
$storageService = App42API::buildStorageService();
$inventory = $storageService->findAllDocuments($dbName,$collectionName);
$jsonDocList = $inventory->getJsonDocList();
foreach( $jsonDocList as $jsonDoc )
{
$products = json_decode($jsonDoc->getJsonDoc());
}
查看
@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>
<?php $i = 1; ?>
@foreach($products as $record)
{
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $record['transactionType']; ?></td>
<td><?php echo $record['numberOfItems']; ?></td>
<td><?php echo $record['totalCost']; ?></td>
<td><?php echo $record['weekOfYear']; ?></td>
<td><?php echo $record['year']; ?></td>
<td><?php echo $record['date']; ?></td>
<td><?php echo $record['dayOfYear']; ?></td>
</tr>
<?php $i++ ;?>
}
@endforeach
</tbody>
</table>
</div>
</div>
@endsection