1. Error: count(): Parameter must be an array or an object that implements Countable (View: ). See Figure 1.

2. Review the code implementation.
PHP
count($user->address_book);
3. Print $user->address_book, and its value is NULL.
4. Adjust the code implementation. When $user->address_book is null, the expression $user->address_book ?? [] evaluates to []; otherwise, it evaluates to $user->address_book.
PHP
count($user->address_book ?? []);
5. As of PHP 7.2.0, count() now emits a warning when an invalid countable type is passed to the value parameter. The environment where the error occurred is running PHP 7.4.26.
