Issue
I am getting an error while trying to display data from the database.This problem occurred by other people who have created posts on this website. but they have a foreach loop and I don't. so all the answers given for this problem do not work.
article controller
public function showwereld($id)
{
$artikels = Artikel::where('id', $id);
return view('pages.show')->with('artikels', $artikels);
}
show.blade.php
<div class="row">
<div class="artikeltitel marginauto">
<div class="col-md-6 offset-md-3">
<h2>{{$artikels->title}}</h2>
<p style="font-weight: bold;">{{$artikels->intro}}</p>
<p>{{$artikels->body}}</p>
</div>
</div>
</div>
Solution
this on controller
public function index()
{
$artikel = Artikel::where('category_id', '1')->first();
return view('pages.wereld',compact('artikel'));
}
in view:
<div class="row">
<div class="artikeltitel marginauto">
<div class="col-md-6 offset-md-3">
<h2>{{$artikel->title}}</h2>
<p style="font-weight: bold;">{{$artikel->intro}}</p>
<p>{{$artikel->body}}</p>
</div>
</div>
</div>
Answered By - Ahmed Atoui
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.