mikebronner / laravel-model-caching

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

The attribute [column3] either does not exist or was not retrieved for model #452

Open jamesRUS52 opened 1 year ago

jamesRUS52 commented 1 year ago

all method not flushing cache when new column requested

$m = MyModel::all(['column1','column2']); $m = MyModel::all(['column1','column2','column3']); var_dump($m->first()->column3);

show error Illuminate\Database\Eloquent\MissingAttributeException The attribute [column3] either does not exist or was not retrieved for model

but get method works properly $m = MyModel::get(['column1','column2']); $m = MyModel::get(['column1','column2','column3']); var_dump($m->first()->column3);

no errors

mikebronner commented 1 year ago

@jamesRUS52 thanks for reporting this. The all() method is probably not indexing the fields passed in. Would love some help from anyone on this to write up a test case, and perhaps even fix the implementation, if someone has some time.

Thanks! :)