March 3, 2020

Eloquent Power Joins

<?php

User::joinRelationship('posts.comments', [
    'posts' => function ($join) {
        $join->postIsPublished();
    },
    'comments' => function ($query) {
        $query->commentIsApproved();
    },
])

If you ever had to use Joins in Laravel before, you know the above snippet is not possible. This was something I always wished I could do, so I finally end up writting a package to do this.

You can check the package and the full documentation on Github. I also wrote an extensive blog post which you can read at the KDG Blog.

View package on Github View blog post