Answer the question
In order to leave comments, you need to log in
How to display data on blade laravel?
Hello! very hard blunt. So, I have the main template index.blade.php Here is its code:
@include('components.header')
<div class="grid">
<div class="grid__width-1">
@yield('sidebar')
</div>
<div class="grid__width-2">
@yield('content')
</div>
</div>
use App\Category;
class HomeController extends Controller
{
public function cat()
{
$cat = Category::all();
$data = ['cat'=>$cat];
return view('main.index', $data);
}
}
@extends('main.index')
@section('sidebar')
<aside>
@foreach($cat as $item)
<a href="{{ route('category',$item->name ) }}" class="aside__link"></a>
@endforeach
</aside>
@endsection
Answer the question
In order to leave comments, you need to log in
You have the index.blade.php template, but you connect main.index
In the [email protected] root, but in fact you don’t have an index, but cat
And if in general, you need to ask the question not how blade works, but how laravel works in general.
Watch some video tutorials on laracast or youtube
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question