Why an undefined variable post ??

Posted 1 year ago by belykia

Hello Everybody : I m a begginer in laravel. I'm trying to update my records in my ManiController.php resource controller, however when I try to route to the controller I am getting thrown the following error: ErrorException (E_ERROR) Undefined variable: post (View: /var/www/html/php/blog/resources/views/edit.blade.php)

i created a tag " Edit" inside the save.blade.php . in order to use edit($id) the function in my ManiController.php resource controller: public function edit($id) { $post=Post::find($id); return view('edit',compact('posts')); }

then i created the function an edit.blade.php where i wrote the form , in order to update the id that i clicked with PUT method like that: public function update(Request $request, $id) {

{{ csrf_field() }} {{ method_field('PUT') }} //...the form

then in public function update(Request $request, $id){} , iwrote the update code with the $post function , but i got everytime the same error , waht s the solution please .

Please sign in or create an account to participate in this conversation.