pdphilip / laravel-elasticsearch

Laravel Elasticsearch: An Elasticsearch implementation of Laravel's Eloquent ORM
MIT License
86 stars 16 forks source link

Collection Cant Parse JSON or ARRAY #3

Closed yuan8 closed 1 year ago

yuan8 commented 1 year ago

i will encode collection to json to strore vue js data but when i was do that always error with message

json_decode(): Argument #1 ($json) must be of type string, array give

dd(json_encode($data->items()));

Screenshot 2023-06-14 at 17 34 29
pdphilip commented 1 year ago

It's not clear to me what you're trying to do, and if this is an issue with plugin or how you're using Laravel. Laravel automatically returns JSON if you return data without a view, no need to encode.

If you're still stuck please give me more context (models, controllers & routes).

Cheers

pdphilip commented 1 year ago

Any feedback @yuan8 ? Happy to help, else will close this issue assuming you figured it out.

yuan8 commented 1 year ago

sory i missing step. that problem only in my code. i used cast in my model to json data item. so when i used model elastic its twice decode. thanks @pdphilip