М
Size: a a a
М
.
М
.
К
.
SG
.
М
$posts is undefined
Make the variable optional in the blade template. Replace {{ $posts }} with {{ $posts ?? '' }}
М
С
.
$posts is undefined
Make the variable optional in the blade template. Replace {{ $posts }} with {{ $posts ?? '' }}
М
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PagesController extends Controller
{
public function index(){
return view('pages.index');
}
public function post(){
return view('pages.post');
}
public function admin(){
return view('pages.admin');
}
}
М
@section('content')
<h1>Це створені пости</h1>
@if(count($posts) > 0)
@foreach($posts as $post)
<div class="card">
<ul class="list-group list-group-flush">
<li class="list-group-item">
<h3><a href="/myblog/public/post/{{$post->id}}">{{$post->title}}</a></h3>
<small>Створено: {{$post->created_at}}</small>
</div>
@endforeach
.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PagesController extends Controller
{
public function index(){
return view('pages.index');
}
public function post(){
return view('pages.post');
}
public function admin(){
return view('pages.admin');
}
}
.
.
.
@section('content')
<h1>Це створені пости</h1>
@if(count($posts) > 0)
@foreach($posts as $post)
<div class="card">
<ul class="list-group list-group-flush">
<li class="list-group-item">
<h3><a href="/myblog/public/post/{{$post->id}}">{{$post->title}}</a></h3>
<small>Створено: {{$post->created_at}}</small>
</div>
@endforeach
SM
К