I'm following a tutorial from Laracasts and I'm making a clone of Twitter. I've got a home.blade.php and a HomeController.php file. In the HomeController I've got a function called index, which calls the home view. He also sends a variable called "tweets".
public function index()
{
return view('home', [
'tweets' => App\Tweet::all()
]);
}
In the home.blade.php file I use blade to show the variable, but I get this error: Undefined variable: tweet (View: C:\wamp64\www\laravel\tweety\resources\views\home.blade.php)
Here's my home.blade.php file:
@extends('layout')
@section('timeline')
<article>
<div class="avatar">
<img src="https://www.w3schools.com/w3css/img_avatar2.png" />
</div>
<div class="content">
<div class="meta">
<span class="author">
{{ $tweet->user->name }}
</span>
<span class="time">
• 10m
</span>
</div>
<div class="text">
{{ $tweet->body }}
</div>
</div>
</article>
@endsection
I've searched on the internet to a solution, but couldn't find one. If you need more information, please tell me.
Thank you! Jeroen van Rensen