I get this error when I try to fetch data from my database based on slug
This is my controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Post;
class BlogController extends Controller
{
public function getSingle($slug) {
// Fetch from the DB based on slug
$post = Post::where('slug', '=', $slug)->get();
// Return the view and pass in the post object
return view('blog.single')->with('post', $post);
}
}
And this is my single.blade.php
@extends('main')
@section('title', '| ')
@section('content')
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1>hi</h1>
<p></p>
</div>
</div>
@endsection
My database has only one row of data and it has the slug named(slug)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire