I am programing a blog using Laravel 5 and bootstrap. The @if control structure seem to not be working written this way in my blade.php:
@section('title')
@if($post)
<p> {{ $post->title}} </p>
@if(!Auth::guest() && ($post->name == Auth::user()->id || Auth::user()->is_admin()))
<button type="button" class="btn btn-default"><a href="{{ url('news.edit')}}">Editer</a></button>
@endif
@endif
@endsection
Here is my function in PostController that calls the blade :
public function index()
{
$post = Post::get();
return view('posts.index', compact('post'));
}
I encounter this error : Undefined property: Illuminate\Database\Eloquent\Collection::$title
I'm new to PHP, I can't seem to see where is the problem. If you have any clue, please help.