I am making a PostController and getting data from posts table
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Posts;
class PostController extends Controller
{
public function index()
{
$posts=Posts::latest()->paginate(5);
// print_r($posts);exit;
return view('post.index',compact($posts))
->with('i',(request()->input('page',1)-1)*5);
}
and my view page code is
@foreach($posts as $post)
<?php echo $post->title; ?>
@endforeach
</table>
@endsection
It's giving me Undefined variable Post in views
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire