I've got an error called
Why show Property (post_meta_keyword) does not exist on this collection instance.
I want to put post_meta_keyword
property to my meta tag, but it show does not exist on this collection.
Here's my Controller:
class PagesController extends Controller
{
public function index()
{
$posts = Post::all();
$banners = Banner::all();
return view('pages/home', compact('posts', 'banners'));
}
}
Here's my meta tags in layouts html:
<title>@yield('title','A default title')</title>
<meta name="keywords" content="@yield('post_meta_keyword','some default keywords')">
<meta name="description" content="@yield('post_meta_description','default description')">
<link rel="canonical" href="{{url()->current()}}" />
And here's my home.blade.php file:
@extends('layouts.layouts')
@section('post_meta_keyword', $posts->post_meta_keyword)
@section('post_meta_description', $posts->post_meta_description)
I also want to call my banner property without looping, it also show does not exist on this collection
Here's my home.blade.php for banner property:
<div class="slide">
<img src="{{ $banners->banner_image }}" alt="">
<div class="info">
<h2>{{ $banners->banner_title }}</h2>
<p>{{ $banners->banner_caption }}</p>
</div>
</div>
How to call property without looping?