Closed
Description
In Laravel 11.19 (https://github.com/laravel/framework/releases/tag/v11.19.0) this PR was added:
This causes this query:
$snapshot = $this->snapshot
->newQuery()
->whereMorphedTo($this->snapshot->subject(), $this->model->getMorphClass())
->latest()
->first();
To result in this SQL:
select * from `model_snapshots` where `related_table`.`subject_type` = ? order by `created_at` desc
Instead of
select * from `model_snapshots` where `subject_type` = ? order by `created_at` desc
Basically it looks for subject_type
on the related_table instead of on the model_snapshots table.
I'm not entirely sure why this is happening.. perhaps the whereMorphedTo
method is the wrong method to use here?
Any chance you could fix this query so that it explicitly looks for subject_type
to avoid this issue?
Something like this perhaps
$snapshot = $this->snapshot
->newQuery()
->where(function ($query) {
$query->where('subject_type', $this->model->getMorphClass());
})
->latest()
->first();
Many thanks!
Metadata
Metadata
Assignees
Labels
No labels