So, I have this array of arrays, something like this:
protected static $base = [
[
'id' => 4,
'createdAt' => 1498638933,
'title' => 'Example 1',
'tables' => [
['title' => '#1', 'createdAt' => 1498638940],
['title' => '#2', 'createdAt' => 1498638941],
['title' => '#3', 'createdAt' => 1498638943],
],
],
[
'id' => 7,
'createdAt' => 1498643923,
'title' => 'Example 2',
'tables' => [
['title' => '#1', 'createdAt' => 1498643925],
['title' => '#2', 'createdAt' => 1498643929],
['title' => '#3', 'createdAt' => 1498643932],
],
these arrays are in a Model code, and I want to display them in my page. Also, from the Model:
public static function getAll() {
sleep(1);
return self::$base;
}
From web.php (routes), I have:
Route::get('/', function () {
$items = \App\MyModel::getAll();
return view('welcome')->with('items', $items);
});
Now, if I try:
{!! dd($items) !!}
All the arrays are displayed, but not in a pretty way. I want only their content. So, I followed these steps (https://laracasts.com/discuss/channels/general-discussion/passing-arrays-to-blade-and-iterating) which became:
@foreach($items['title'] as $title => $content)
{{ $title }}
@foreach ($content as $tables => $item)
{{ $tables . ' => ' . $item }}
@endforeach
@endforeach
But 'title' isn't recognized, and I've tried some things like this, nothing works. What I might be missing?