Error while mounting Foreach Laravel 5.1

1

I'm trying to mount a filter where I'm looking for some options from the DB I made a foreach to bring this data from the DB but it's bringing an error:

Trying to get property of non-object

Follow my code:

Controller

public function index()
{
    $categoria = $this->catimage->get();

    return view('administrator.images.index', compact('categoria'));
}

View

<div class="row">
<ul class="simplefilter">
Filtros:
<li class="active" data-filter="all">All</li>
@foreach ($categoria as $categoria)
<li data-filter="{{$categoria ->id}}">{{$categoria ->title}}</li>
@endforeach
</ul>
</div>
    
asked by anonymous 29.06.2016 / 22:16

1 answer

1

With compact does not work. Here's how:

Controller:

return view('administrator.images.index', ['categoria' => $categoria]);
    
30.06.2016 / 14:53