ozdemirburak/laravel-9-simple-cms

Count parameter error for blog / page

greenlevel opened this issue · 2 comments

So i got everything installed, but i get an error when i click on specific posts or page.

count(): Parameter must be an array or an object that implements Countable (View: /home/vagrant/code/ozz/resources/views/application/article/index.blade.php)

ErrorException (E_ERROR)
count(): Parameter must be an array or an object that implements Countable (View: /home/vagrant/code/ozz/resources/views/application/page/index.blade.php)

I suppose it has to do with this.
PHP changed count() behavior?
https://wiki.php.net/rfc/counting_non_countables

As I have php 7.2 installed, i will get this error.

I have just removed the if count statement for now.

Maybe there is another work around to check the the pages/blog, which is suitable for 7.2.

That is not related with PHP 7.2, the variable is not countable when there are not any items there, so it's better to check with !empty instead of count, I updated the code.

Feel free to reopen another issue if something unexpected occurs again.