PHP code example of kirschbaum-development / eloquent-power-joins

1. Go to this page and download the library: Download kirschbaum-development/eloquent-power-joins library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kirschbaum-development / eloquent-power-joins example snippets


User::select('users.*')
    ->join('posts', 'posts.user_id', '=', 'users.id')
    ->join('comments', 'comments.post_id', '=', 'posts.id');

User::joinRelationship('posts.comments');

// Query relationship existence using joins instead of where exists
User::powerJoinHas('posts');

// Order by a related column
User::orderByPowerJoins('profile.city');

// Order by an aggregation on a related table
Post::orderByPowerJoinsCount('comments.id', 'desc');