Skip to content

Added MorphTo and anonymous join support

Choose a tag to compare

@tylernathanreed tylernathanreed released this 12 Jul 16:43
· 131 commits to master since this release

Morph To example:

Image::query()->joinMorphRelation('imageable', Post::class);
// SQL: select * from "images" inner join "posts" on "posts"."id" = "images"."imageable_id" and "images"."imageable_type" = ?

Anonymous Join example:

$relation = Relation::noConstraints(function () {
    return (new User)
        ->belongsTo(Country::class, 'country_name', 'name');
});

User::query()->joinRelation($relation);
// SQL: select * from "users" inner join "countries" on "countries"."name" = "users"."country_name"

See readme for more details.