更新Laravel中的表格

I need help updating a blog post that I am creating in laravel. I am using the the update method in a restful controller to handle this. It seems to me that the form is being submitted to the right function within the controller (the update method) but the table in the database is not reflecting the change.

Here is what I have for the form:

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row">
    <div class="col-md-8 col-md-offset-2">
        <div class="panel panel-default">
            <div class="panel-heading">Register</div>
            <div class="panel-body">
                <form class="form-horizontal" role="form" method="POST" action="{{ url('/posts/$post_id') }}">
                    {{ csrf_field() }}
                    <input type="hidden" name="_method" value="PUT">
                    <div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
                        <label for="title" class="col-md-4 control-label">Title</label>

                        <div class="col-md-6">
                            <input id="title" type="text" class="form-control" name="title" value="{{ !empty(old('title')) ? old('title') : $post->title }}" required autofocus>

                            @if ($errors->has('title'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('title') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('content') ? ' has-error' : '' }}">
                        <label for="content" class="col-md-4 control-label">Content</label>

                        <div class="col-md-6">
                            <textarea id="content" type="text" class="form-control" name="content"  required rows="15" cols="20">{{ !empty(old('content')) ? old('content') : $post->content }}</textarea>

                            @if ($errors->has('content'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('content') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-6 col-md-offset-4">
                            <button type="submit" class="btn btn-primary">
                                Post
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</div>
 @endsection

Here is the controller function

public function update(PostRequest $request, $id)
{
    $title = $request->title;
    $content = $request->content;

    DB::table('posts')->where('id', $id)->update(['title' => $title, 'content' => $content]);

    return 'Post was updated.<br>' . $title . '<br>' . $content;
}

I added the $title and the $content variables to the return statement just to see if they were going through ok and being captured correctly. When I submit the form, I get the return statement as it is written here. That at least tells me that the form is submitting to this function correctly, but as I said, the database does not reflect the change. Does anyone know what I am doing wrong here? Not sure if its the update command that isn't working correctly for the stubbing of the PUT method using the hidden inout field.

Thanks in advance.

the update method returns boolean itself so check if it is true then this means the query is success

    public function update(PostRequest $request, $id)
    {
        $title = $request->title;
        $content = $request->content;

        if (DB::table('posts')->where('id', $id)->update(['title' => $title, 'content' => $content])) {
            return 'Post was updated.<br>' . $title . '<br>' . $content;
        } else {
            return 'Failed to update Post';
        }
    }

Try this below, only you are validating the input in the PostRequest file

     public function update(PostRequest $request, $id)
    {
       $title = $request->input('title');
       $content = $request->input('content');

      if (DB::table('posts')->where('id', $id)->update(['title' => $title, 'content' => $content])) {
        return 'Post was updated.<br>' . $title . '<br>' . $content;
      } else {
        return 'Failed to update Post';
      }
    }        

or if you are using Post model, then use it

     public function update(PostRequest $request, $id)
    {
       $title = $request->input('title');
       $content = $request->input('content');

      if (POST::find($id)->update([$title, $content]) {
        return 'Post was updated.<br>' . $title . '<br>' . $content;
      } else {
        return 'Failed to update Post';
      }
    }        

or if you are using Post model, then use it

     public function update(PostRequest $request, $id)
    {

      if (POST::find($id)->update($request->all()) {
        return 'Post was updated.<br>' . $title . '<br>' . $content;
      } else {
        return 'Failed to update Post';
      }
    }        

I think it is helpful for you..