A
A
Amenov_Abdul2019-04-16 14:23:12
Laravel
Amenov_Abdul, 2019-04-16 14:23:12

How to output array from Laravel controller?

There is an array

$gridLinks = [
      [
        'title' => 'Пользователи',
        'icon' => 'images/cabinet/resume.svg',
        'route' => 'adminUser'
      ],
      [
        'title' => 'Новости',
        'icon' => 'images/cabinet/resume.svg',
        'route' => 'home'
      ],
      [
        'title' => 'Отзывы',
        'icon' => 'images/cabinet/resume.svg',
        'route' => 'home'
      ],
      [
        'title' => 'Города/Районы/Микрорайоны',
        'icon' => 'images/cabinet/resume.svg',
        'route' => 'home'
      ],
      [
        'title' => 'Категории',
        'icon' => 'images/cabinet/resume.svg',
        'route' => 'home'
      ],
      [
        'title' => 'Выйти',
        'icon' => 'images/cabinet/exit.svg',
        'route' => 'logout'
      ]
    ];

I add a variable to the view I print the array with the help I print the array to the view like this
return view('admin.index', compact('gridLinks'));
dd($gridLinks);
@foreach($gridLinks as $link)
            <a class="gridLinksItem" href="">
              <h3 class="gridLinksItem__title">{{ $link->title }}</h3>
            </a>
          @endforeach

And they write to me:
Trying to get property 'title' of non-object (View: C:\xampp\htdocs\myteacher.local\resources\views\admin\index.blade.php)
What's the catch? I can't understand - it's just an ordinary array.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konata Izumi, 2019-04-16
@Amenov_Abdul

$link->title replace with $link['title']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question