Closed MannikJ closed 3 months ago
Hi @MannikJ, Thanks for reporting. This is caused by a breaking change in Laravel 11.15. I'll work on a fix.
I released a new version with the fix. The issue was that HasOneThrough
no longer is a subclass of HasManyThrough
and so $relation instanceof HasManyThrough
isn't true
anymore.
staudenmeir/eloquent-has-many-deep: v1.20.1 laravel/framework: v11.15.0
Since updating from Laravel 10 to 11 my
previewFile
relation doesn't work anymore.The exception is quite obvious:
The error comes from the following function in Staudenmeir\EloquentHasManyDeep\Eloquent\Traits\ConcatenatesNativeRelationships
I have not yet fully checked why it has worked before and why it throws an error now, but I guess there might have been a restructuring in the inheritance hierarchy of the relation classes so that HasOneThrough relation is not allowed anymore due to the failing
instanceof
check.My example code, although simplified a bit, is still a bit too complicated, but I think the error message speaks for itself anyway:
App\Models\Job.php
App\Models\Task.php: