我一直在尝试将我的网络应用程序连接到BaaS,名为app42-apphq.shefertz.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发布于 2015-07-13 08:21:41
我希望这能帮到你
控制器
$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>
@endsectionhttps://stackoverflow.com/questions/30982271
复制相似问题