PHP code example of staudenmeir / eloquent-eager-limit-x-laravel-adjacency-list

1. Go to this page and download the library: Download staudenmeir/eloquent-eager-limit-x-laravel-adjacency-list 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/ */

    

staudenmeir / eloquent-eager-limit-x-laravel-adjacency-list example snippets


class User extends Model
{
    use \Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Eloquent\HasEagerLimitAndRecursiveRelationships;
}

$users = User::with([
    'descendants' => function ($query) {
        $query->breadthFirst()->limit(10);
    }
])->get();

class Node extends Model
{
    use \Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Eloquent\HasEagerLimitAndGraphRelationships;
}