← Back to API Generator Support
I m getting this error
https://imgur.com/a/MOhxa8S
while consuming api which i created on october cms with php 7.2.
I guess it's because of count's behavior change is done in php 7.2 onwards .Is there any workaround?
Any help will be appricated.
Thanks in advance
demrich32641 said:
Was there any work around found for this? I ran into the same issue
Nope. Instead, I used built-in Rest API provided by October CMS. I have created Routes.php in models then included model I want to use then returned modelname::All() as response for given api url
parth32067 said:
demrich32641 said:
Was there any work around found for this? I ran into the same issue
Nope. Instead, I used built-in Rest API provided by October CMS. I have created Routes.php in models then included model I want to use then returned modelname::All() as response for given api url
Ahh, ok. That might be the better route. I found the fix for this, you simply change any instance of count() to !isempty() in the api controllers and helpers. Author might want to update, as its deprecated.
A little late on the conversation, but you can wrap your $data into a collection like this: collect($data).
Just use the toArray() method to convert the post in a array. Change:
$data = $this->Post->where('id',$id)->first();
to
$data = $this->Post->where('id',$id)->first()->toArray();
Do this in every controller.
1-6 of 6