title: update column value in laravel 5.4
body: <blockquote>
    <p>i want to update privacy of a post</p>
    
    <p>my controller</p>
  </blockquote>
  
  <pre><code>   public function changePostsPrivacy(Request $request){
              $userId = $request-&gt;user()-&gt;id;
              $postid = $request-&gt;get('id');
              //dd($postid);
              $privacy = $request-&gt;get('privacy');//dd($privacy);
              $user = User::where(['id' =&gt; $userId, 'hide' =&gt; 0])-&gt;first();
              if($user &amp;&amp; $postid &amp;&amp; in_array($privacy, [1,0])){
                  DB::table('posts')-&gt;update(['creator_id' =&gt; $userId, 'id' =&gt; $postid],[
                      'privacy' =&gt; $privacy,
                  ]);
              }
          }
  </code></pre>
  
  <blockquote>
    <p>Route :</p>
  </blockquote>
  
  <pre><code> Route::group(['middleware'=&gt;['auth:api', \App\Http\Middleware\OnlyRegisteredUsers::class]], function(){
          /**
           * Group for registered users only APIs
           */
          Route::post('changePostsPrivacy','UserController@changePostsPrivacy');
      });
  </code></pre>
  
  <blockquote>
    <p>Migration</p>
  </blockquote>
  
  <pre><code> public function up()
      {
          Schema::create('posts', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('title');
              $table-&gt;longText('content');
              $table-&gt;string('short_description');
              $table-&gt;unsignedInteger('media_id')-&gt;nullable();
              $table-&gt;foreign('media_id')-&gt;references('id')-&gt;on('medias');
              $table-&gt;unsignedInteger('creator_id');
              $table-&gt;foreign('creator_id')-&gt;references('id')-&gt;on('users');
              $table-&gt;boolean('hide')-&gt;default(0);
              $table-&gt;timestamps();
          });
      }
  </code></pre>
  
  <blockquote>
    <p>new column added in this this migration</p>
  </blockquote>
  
  <pre><code> public function up()
          {
              Schema::table('posts', function (Blueprint $table) {
                  $table-&gt;integer('privacy')-&gt;after('creator_id');
              });
          }
  </code></pre>
  
  <blockquote>
    <p>when i want to add privacy to any post it gives me an error</p>
    
    <p>"message": "SQLSTATE[23000]: Integrity constraint violation: 1451
    Cannot delete or update a parent row: a foreign key constraint fails
    (<code>webdb</code>.<code>comments</code>, CONSTRAINT <code>comments_post_id_foreign</code> FOREIGN KEY
    (<code>post_id</code>) REFERENCES <code>posts</code> (<code>id</code>)) (SQL: update <code>posts</code> set
    <code>creator_id</code> = 17, <code>id</code> = 48)",</p>
  </blockquote>