I'm facing strange case. I face an error in production env not while in dev it's working fine.
Development: Laravel 5.4.28 PHP 7.0.13 MYSQL 5.7.17
Production: Laravel 5.4.28 PHP 7.2.1 MYSQL 5.7.20
In implementation code. I used:
namespace App; use Illuminate\Support\Facades\Storage; use Laravel\Scout\Searchable; use Illuminate\Database\Eloquent\Model; class Artwork extends Model { use Searchable;
In development it works fine. But in production it gives me this error: count(): Parameter must be an array or an object that implements Countable in Builder.php (line 936)
as you can see in this pic:
Any idea what is the reason behind this? and how to fix?
The count() function returns the number of elements in an array.
Array#count() : count() is a Array class method which returns the number of elements in the array. It can also find the total number of a particular element in the array. Syntax: Array. count() Parameter: obj - specific element to found Return: removes all the nil values from the array.
The count() function is used to count the elements of an array or the properties of an object. Note: For objects, if you have SPL installed, you can hook into count() by implementing interface Countable. The interface has exactly one method, Countable::count(), which returns the return value for the count() function.
Definition and Usage. The is_array() function checks whether a variable is an array or not. This function returns true (1) if the variable is an array, otherwise it returns false/nothing.
Put this code at the beginning of your route
file, it will work fine
if(version_compare(PHP_VERSION, '7.2.0', '>=')) { error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With