title: Error when updating a blog post in laravel
body: <p>This is the error in the log:</p>
  <pre><code>production.ERROR: count(): Parameter must be an array or an object that implements Countable {&quot;userId&quot;:7,&quot;exception&quot;:&quot;[object] (ErrorException(code: 0): count(): Parameter must be an array or an object that implements Countable at /var/www/new_site/app/Http/Controllers/postsController.php:515)
  </code></pre>
  <p>When I update a post, it gives me a 500 server error.  When I create a post, the post is created with no problems but I get redirected to a blank screen.  But I can't seem to update a post.</p>
  <p>Here's the actual code for post updating:</p>
  <pre><code>//update post in DB
  
  public function updatepost(Request $request){
  
      $this-&gt;validate($request, [
  
      'thumbnail' =&gt; 'mimes:jpg,jpeg,png|max:800',
  
      'file1' =&gt; 'mimes:rar,zip|max:10000',
  
      ]);
  
  
  
      $file1=$request-&gt;file('file1');
  
      if(is_null($request-&gt;file('file1'))){
  
        $p=posts::where('id', '=', $request['id'])-&gt;first();
  
        $attmt1=$p-&gt;attachment;
  
      }
  
      else
  
      {
  
      $upload_dir='uploads';
  
      $attmt1=$file1-&gt;getClientOriginalName();
  
      $move=$file1-&gt;move($upload_dir, $attmt1);
  
      }
  
  
  
      if(is_null($request-&gt;file('thumbnail'))){
  
        $p=posts::where('id', '=', $request['id'])-&gt;first();
  
        $image=$p-&gt;thumbnail;
  
      }
  
      else
  
      {
  
        $img=$request-&gt;file('thumbnail');
  
        $upload_dir='new_site/thumbnails';
  
        $image=$img-&gt;getClientOriginalName();
  
        $move=$img-&gt;move($upload_dir, $image);
  
        //end thumbnail process 
  
      }
  
      $posts = new posts();
  
      $title=$request['title'];
  
      $content=htmlentities($request['editor1']);
  
      $keywords=$request['keywords'];
  
      $video=$request['video'];
  
      $category=$request['category'];
  
      $type=$request['type'];
  $slug = str_slug($request-&gt;slug, '-');
  
      $school=$request['school'];
  
  
  
      //process url
  
      $find=array(&quot;,&quot;,&quot;.&quot;,&quot; &quot;);
  
      $replace=array(&quot;&quot;,&quot;&quot;,&quot;-&quot;);
  
      $titleurl = str_replace($find,$replace, $title);
  
     $url='articles/'.strtolower($titleurl);
  
      $check=posts::where('url', '=', $url)-&gt;first();
  
      if(count($check)&gt;1){
  
        return redirect()-&gt;back()
  
          -&gt;with('message', 'Looks like there is a similar topic. please review post');
  
      }
  
      //end url process
  
  
  
      $check=posts::where('id', $request['id'])
  
      -&gt;update([
  
        'title' =&gt; $title,
  
        'content' =&gt;$content, 
  
        'keywords' =&gt;$keywords, 
  
        'video' =&gt;$video, 
  
        'category' =&gt;$category, 
  
        'thumbnail' =&gt;$image, 
  
        'post_type' =&gt;$type, 
  
        'url' =&gt;$url, 
        'slug' =&gt;$slug,
  
        'school' =&gt;$school, 
  
        'attachment' =&gt;$attmt1, 
  
        ]);
  
      return redirect()-&gt;back()
  
      -&gt;with('message', 'Post updated Sucessful');
  
  }
  </code></pre>
  <p>This is line 515:</p>
  <pre><code>if(count($check)&gt;1){
  </code></pre>
  <p>Any ideas on what problem may be?</p>