mardi 8 juin 2021

Laravel 5.4 : Undefined variable: post

Why am I getting undefined variable post error?

My controller file is:

class CommentController extends Controller{
    public function index(){        
     $post = Comment::all()->toArray();
     return view('layout_frontend.readmore',compact('post'));
    }

and my view file is :

<div class = "row">
       @foreach ($post as $row)
         <div class = "comment">
            <p>  </p>
            <br><p></p></br>
         </div>       
       @endforeach  
    </div>  

my routes are:

Route::get('/home', 'HomeController@index')->name('home');
Route::get('/blog', 'BlogController@blog')->name('blog');
Route::post('/readmore', 'CommentController@store')->name('store');
Route::get('/readmore', 'BlogController@readmore')->name('readmore');


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire