マルチ配列を読み書きするループがありますが、各エントリをブレード構文を使用してスタイルする必要があります。PHPでHtmlをエコーアウトしようとしましたが、うまくいきませんでした。
これは私がブレード構文でやろうとしていることです
echo '<td>'.$key.'</td>';
配列
array:2 [▼
0 => {#173 ▼
+"Name": "Rama Berger"
+"StockName": "apple"
+"price": 100
+"Date": "2016-01-07 17:31:06"
}
1 => {#172 ▼
+"Name": "Rama Berger"
+"StockName": "apple"
+"price": 11
+"Date": "2016-01-07 20:00:38"
}
]
意見
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Name</th>
<th>Stock</th>
<th>Order Amount</th>
<th>Date</th><br>
</tr>
</thead>
<tbody>
@foreach($History as $Past)
@foreach($Past as $key)
<tr>
<td>{{$key}}</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
コントローラ
<?php
namespace App\Http\Controllers;
use \View as View;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Request;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class RequestController extends BaseController
{
public function GetHistory(){
$name = Auth::user()->name;
$History = DB::table('History')->select('Name', 'StockName', 'price', 'Date')->where('StockName', '=', 'apple')->get();
return view('pages.home')->with('History', $History);
}
}