title: Laravel Checking if Array or Collection is not Empty to run
body: <p>I have an object of <strong>$person</strong> as below:</p>
  <pre><code>$person = Person::where('id', $id)-&gt;first();
  </code></pre>
  <p>According to which <strong>$person</strong> exists or not I load other data:</p>
  <pre><code>if($person) {
      $person-&gt;family_members = FamilyMemberController::FamilyMemberOf($person-&gt;id);
  } else {
      $person-&gt;family_members = [];
  }
  </code></pre>
  <p>In the view file, I check the <strong>$person-&gt;family_members</strong> if not empty and exists to add a generated value :</p>
  <pre><code>if(!empty(array_filter($person-&gt;family_members))) {
      // my code
  }
  </code></pre>
  <p>But it throws an error:</p>
  <blockquote>
  <p>array_filter(): Argument #1 ($array) must be of type array, Illuminate\Database\Eloquent\Collection given</p>
  </blockquote>
  <p>I need to check this <strong>$person-&gt;family_members</strong> to make sure whether it's an array or a collection is not empty.</p>