при нажатии на блок поста в своей cms появляется ошибка.
Вот код PostController. php
<?php
namespace App\Http\Controllers\Blog;
use App\Http\Controllers\Controller;
use App\Post;
use Illuminate\Http\Request;
use App\Tag;
use App\Category;
class PostsController extends Controller
{
public function show(Post $post) {
return view('blog.show')->with('post', $post);
}
public function category(Category $category) {
return view('blog.category')
->with('category', $category)
->with('posts', $category->post()->searched()->simplePaginate(3))
->with('categories', Category::all())
->with('tags', Tag::all());
}
public function tag(Tag $tag) {
return view('blog.tag')
->with('tag', $tag)
->with('categories', Category::all())
->with('tags', Tag::all())
->with('posts', $tag->posts()->searched()->simplePaginate(3));
}
}
вот код Post. php Модель
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;
use App\Category;
class Post extends Model
{
use SoftDeletes;
protected $fillable = [
'title', 'description', 'content', 'image', 'published_at', 'category_id', 'user_id',
];
/**
* Delete post image from storage
* HHE
* @return void
*/
public function deleteImage() {
Storage::delete($this->image);
}
public function category() {
return $this->belongsTo(Category::class);
}
public function tag() {
return $this->belongsToMany(Tag::class);
}
/**
*
* @return bool
*/
public function hasTag($tagId) {
return in_array($tagId, $this->tags->pluck('id')->toArray());
}
public function user() {
return $this->belongsTo(User::class);
}
public function scopeSearched($query) {
$search = request()->query('search');
if (!$search) {
return $query;
}
return $query->where('title', 'LIKE', "%{$search}%");
}
}
Вот код show.blade . php
@extends('layouts.blog')
@section('title')
{{ $post->title }}
@endsection
@section('header')
<header class="header text-white h-fullscreen pb-80" style="background-image: url({{ asset($post->image) }});" data-overlay="9">
<div class="container text-center">
<div class="row h-100">
<div class="col-lg-8 mx-auto align-self-center">
<p class="opacity-70 text-uppercase small ls-1">
{{ $post->category->name }}
</p>
<h1 class="display-4 mt-7 mb-8">
{{ $post->title }}
</h1>
<p><span class="opacity-70 mr-1">By</span> <a class="text-white" href="#">
{{ $post->user->name }}
</a></p>
<p><img class="avatar avatar-sm" src="{{ Gravatar::src($post->user->email) }}" alt="..."></p>
</div>
<div class="col-12 align-self-end text-center">
<a class="scroll-down-1 scroll-down-white" href="#section-content"><span></span></a>
</div>
</div>
</div>
</header><!-- /.header -->
@endsection
@section('content')
<main class="main-content">
<div class="section" id="section-content">
<div class="container">
{!! $post->content !!}
<div class="row">
<div class="gap-xy-2 mt-6">
@foreach($post->tags as $tag)
<a class="badge badge-pill badge-secondary" href="{{ route('blog.tag', $tag->id) }}">
{{ $tag->name }}
</a>
@endforeach
</div>
</div>
</div>
</div>
</div>
<div class="section bg-gray">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<hr>
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = "{{ config('app.url') }}/blog/posts/{{ $post->id }}"; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = "$post->id"; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://unicare-clinic.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</div>
</div>
</div>
</main>
@endsection
и ошибка Недействительный аргумент для foreach () (View: C: \ xampp \ htdocs \ blogcms \ resources \ views \ blog \ show.blade. php )
Любая помощь будет принята с благодарностью, спасибо, ребята.