PHP code example of kitloong / eloquent-power-joins-with-compoships

1. Go to this page and download the library: Download kitloong/eloquent-power-joins-with-compoships 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/ */

    

kitloong / eloquent-power-joins-with-compoships example snippets


use Awobaz\Compoships\Compoships;
use Kirschbaum\PowerJoins\PowerJoins;

class User extends Model
{
    use PowerJoins;
    use Compoships;
    
    public function posts()
    {
        return $this->hasMany(
            Post::class, 
            ['team_id', 'category_id'], 
            ['team_id', 'category_id']
        );
    }
}

User::joinRelationship('posts');