eloquent-driver
eloquent-driver copied to clipboard
`fresh()` not returning new instance
Description
If you are editing an entry, save it and try to get a new instance with the fresh() method you will get the outdated entry back.
Example
$entry->set('title', 'New Title');
$entry->save();
dd(
$entry->fresh()->title,
\Statamic\Facades\Entry::query()->where('id', $entry->id)->first()->title,
);
This will output two different values.
The reason for this problem is the blink cache in the find() method.
https://github.com/statamic/eloquent-driver/blob/2c4a775accb30803120b009209bc80ebcca23093/src/Entries/EntryRepository.php#L20-L25
I've opened a PR here: https://github.com/statamic/eloquent-driver/pull/64
That was fast! I just wanted to submit a PR too, but I guess you were faster :) Thanks @ryanmitchell 🚀
@helloiamlukas I feel responsible :)