public function index(MasterSupervisorRepository $masters,
                          SupervisorRepository $supervisors)
    {
        $masters = collect($masters->all())->keyBy('name')->sortBy('name');

        $supervisors = collect($supervisors->all())->sortBy('name')->groupBy('master');

        return $masters->each(function ($master, $name) use ($supervisors) {
            $master->supervisors = $supervisors->get($name);
        });
    }
public function index(MasterSupervisorRepository $masters,
                          SupervisorRepository $supervisors)
    {
        $masters = collect($masters->all())->keyBy('name')->sortBy('name');

        $supervisors = collect($supervisors->all())->sortBy('name')->groupBy('master');

        return $masters->each(function ($master, $name) use ($supervisors) {
            $master->supervisors = $supervisors->get($name);
        });
    }
public function index ( MasterSupervisorRepository $ masters , SupervisorRepository $ supervisors ) { $ masters = collect ( $ masters -> all ( ) ) -> keyBy ( 'name' ) -> sortBy ( 'name' ) ; $ supervisors = collect ( $ supervisors -> all ( ) ) -> sortBy ( 'name' ) -> groupBy ( 'master' ) ; return $ masters -> each ( function ( $ master , $ name ) use ( $ supervisors ) { $ master -> supervisors = $ supervisors -> get ( $ name ) ; } ) ; }
Get all of the master supervisors and their underlying supervisors.

@param  \Laravel\Horizon\Contracts\MasterSupervisorRepository  $masters
@param  \Laravel\Horizon\Contracts\SupervisorRepository  $supervisors
@return \Illuminate\Support\Collection
Get all of the master supervisors and their underlying supervisors .