Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.x] Allow to use alias of morphed model (#34032)
* Allow to use alias of morphed model At the moment if you use hasMorph() you need to use model class name and can't use alias, you need to use `Relation::getMorphedModel`. But this is already done when you use `*` which auto discover morphed relations. Moving this conversion for all case allow to use directly aliases. Example now: ``` $morphable = [ "App\AnotherModel", Relation::getMorphedModel('alias') ]; $dataset = MyModel::query() ->whereHasMorph('morphable', $morphable) ->with('morphable') ->orderBy('id') ->limit(50) ->get() ->groupBy('morphable_type'); ``` With this change can be: ``` $morphable = [ "App\AnotherModel", 'alias', 'another', "App\YetAnotherModel", ]; $dataset = MyModel::query() ->whereHasMorph('morphable', $morphable) ->with('morphable') ->orderBy('id') ->limit(50) ->get() ->groupBy('morphable_type'); ``` * Update QueriesRelationships.php
- Loading branch information