The error "must be of type Countable|array, null given" occurs when you try to use the count() function on a variable that is not an array or does not implement the Countable interface. In this case, it seems that one or more of the variables $companies, $users, or $activeJobs is null.
To fix this error, you can check if the variables are null before using the count() function. Here's an example of how you can modify the code to handle null values:
const data = {
employes: {{ $companies ? count($companies) : 0 }},
users: {{ $users ? count($users) : 0 }},
jobs: {{ $activeJobs ? count($activeJobs) : 0 }}
};
In the modified code, we use the ternary operator (?) to check if the variables are null. If they are not null, we use the count() function as before. Otherwise, we use a default value of 0.
Note: Make sure to replace the {{ }} with the appropriate syntax for your template engine or JavaScript framework.