Cannot Update my data from my edit from

Posted 8 months ago by towhid

This is my edit form

<form class="col-md-6" method="PUT" action="/posts">
          <div class="form-group">
            <label for="title">Title</label>
            <input type="text" class="form-control" id="title" name="title" value="{{$post->title}}">
          <div class="form-group">
            <label for="body">Body</label>
            <textarea class="form-control" rows="5" name="body">{{$post->body}}</textarea>
          <button type="submit" class="btn btn-success">Update</button>

This is my edit and update controller code

   public function edit($id)
        return view('post.edit',compact('post'));

    public function update(Request $request, $id)
        $post->title = $request->input('title');
        $post->body = $request->input('body');
        return redirect('/posts')->with('success','Post Updated');

this is my model code


namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model

this is my route code


but not work -- please -- tell me- the - probelm

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.