DataTable error count(): Parameter must be an array or an object that implements Countable

DataTable error count(): Parameter must be an array or an object that implements Countable

nadir1122nadir1122 Posts: 2Questions: 1Answers: 0

I am using Laravel for this, all other things and functions work properly. Datatable call in other functions work properly but in this function it throws
count(): Parameter must be an array or an object that implements Countable

Code is as following

 $clicks=History::orderBy('id','DESC');
  return DataTables::of($clicks)->make(true);

Does anyone know why is it happening?

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    That error isn't from DataTables, I'm afraid - I did a search for "Countable" on the code and there's no match - so it must be something else triggering it in your stack.

    Colin

  • nadir1122nadir1122 Posts: 2Questions: 1Answers: 0

    If i remove Datatable::of($clicks)->make(true)

    then everything works properly. So this is the error in the datatable call.

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    It'll be the Laravel integration, so at least a layer above DataTables. It would be worth looking on SO, there are a few threads with that error, for example here.

    Colin

This discussion has been closed.