mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.25k stars 212 forks source link

Parameter $columns can be a string, and must be converted to expected array #281

Closed jayprakashji closed 5 years ago

jayprakashji commented 5 years ago

With Eloquent you can do both of these: Model::where('id', $id)->get(['column']) Model::where('id', $id)->get('column')

Builder is converting it. https://github.com/laravel/framework/blob/5.8/src/Illuminate/Database/Query/Builder.php#L2117

But makeCacheKey() is expecting array.

I took the same approach that laravel has, into makeCacheKey().

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-2.6%) to 93.091% when pulling 14dcb6b4a11f8582883df8f18bc689b55f6a59ea on jayprakashji:master into 536316a8d542b1dd90dcf849a31fde3ee7b0fa1c on GeneaLabs:master.

mikebronner commented 5 years ago

Thanks for submitting this. I will take a look, probably later today. :)

mikebronner commented 5 years ago

@jayprakashji I went ahead and fixed this as the root of the cause, instead of updating the makeCacheKey() method and added a test case for it. Thanks again!