Issue
I have the following problem related to displaying the details (title, content) of the blog posts.
I would like only the information in the post I accessed to appear.
in controller i have:
public function site($posts)
{
$theme = get_option('active_theme','default');
if( file_exists( resource_path() . "/views/theme/$theme/postare/$posts.blade.php") ){
return view("theme.$theme.template.$posts");
}else{
abort(404);
}
// $post = Posts::where('posts_id', $posts->id)->get();
}
In blade i have:
@foreach(\App\Posts::all() as $posts)
<div class="col-md col-lg ml-auto mr-auto">
<h4 class="text-primary">Sub title</h4>
<h2 class=""><strong>{{ get_array_data($posts->title) }}</strong></h2>
<svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 0 40 20" width="40" class="mb-30 svg-primary" src="images/gallery/decor/line-h-1.svg" alt="sep"><path d="m0 8h40v4h-40z" fill-rule="evenodd"></path></svg>
<p class="">{!! get_array_data($posts->content) !!}</p>
</div>
@endforeach
Solution
Thank you for your help. I solved it like this: in controller: public function show(Posts $posts, $id)//show only selected post
{
$posts = Posts::find($id);
return view('theme.default.template.post_detalii', compact(['posts']));
}
in blade:
<div class="col-md col-lg ml-auto mr-auto">
<h4 class="text-primary">Sub title</h4>
<div itemscope itemprop="mainEntity" itemtype="https://schema.org/Question">
<h2 itemprop="name" class=""><strong>{!!( get_array_data($posts->title) )!!}</strong></h2>
<svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 0 40 20" width="40" class="mb-30 svg-primary" src="images/gallery/decor/line-h-1.svg" alt="sep"><path d="m0 8h40v4h-40z" fill-rule="evenodd"></path></svg>
<div itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer">
<p itemprop="text" class="">{!!( get_array_data($posts->content) )!!}</p>
</div>
Answered By - Marian Giuglea
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.