findnew laravel code example
Example 1: @foreac laravel
public function index()
{
$posts = Post::all();
return view('Pages.welcome')->with('posts', $posts);
}
Example 2: @foreac laravel
@if(count($posts) > 1)
@foreach($posts as $post)
<h2><a href="/posts/{{$post->id}}">{{$post->title}}</a></h2>
@endforeach
@else
</p>no posts found</p>
@endif