Бэкэнд app42 как сервис

Я пытался подключить свое веб-приложение к 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

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
Другие вопросы по тегам