What does stop working mean; what error message (or change in expected behaviour) was observed?
Aug 18, 2024
7
Level 3
why search stop working after i add attribute attributes to #[computed] property
- without any attribute in computed is working
- with pristst #[Computed(persist:true)] or #[Computed(cache:true)] search stoped working
#[Computed()]
public function transactions()
{
return Transaction::query()
->when((bool) $this->filters['status'], function ($query) {
$query->where('status', $this->filters['status']);
}
->search('title', $this->search)->orderBy($this->sortField, $this->sortDirection)->paginate(10);
}
Level 104
@Respect okay, I understand. I believe the problem is what you are doing rather than how
If you are have cached the result of the query; why would you expect the resultset to change if you do not bust the cache? Let's say you persist with a very short TTL, e.g. 1 second; I suppose that will work, right?
#[Computed(persist: true, seconds: 1)]
public function transactions()
{
// ...
But now you have to ask yourself, why would I cache the results for only one second, it makes no sense.
1 like
Please or to participate in this conversation.