src/Commands/DefaultCommand/RelationIndexCommand.php
public function handle()
    {
        $class = $this->modelClass;
        $relation = $this->relation;
        $relationClass = $this->relationClass;

        $model = $class::findOrFail($this->id);

        $perPage = $this->getPerPageFromModelClass($relationClass);
        $fields = $this->getFieldsFromRequest($relation);

        $query = $model->$relation();
        $query = $this->addWhereStatements($query, $class);

        // If `count` param is present, return early since we don't want to sort or embed
        if (Request::get('count')) {
            return [ 'count' => $query->count() ];
        }

        return $query->withRequestSort()->withRequestEmbed()->paginate($perPage, $fields);
    }
public function handle()
    {
        $class = $this->modelClass;
        $relation = $this->relation;
        $relationClass = $this->relationClass;

        $model = $class::findOrFail($this->id);

        $perPage = $this->getPerPageFromModelClass($relationClass);
        $fields = $this->getFieldsFromRequest($relation);

        $query = $model->$relation();
        $query = $this->addWhereStatements($query, $class);

        // If `count` param is present, return early since we don't want to sort or embed
        if (Request::get('count')) {
            return [ 'count' => $query->count() ];
        }

        return $query->withRequestSort()->withRequestEmbed()->paginate($perPage, $fields);
    }
Execute the command.

@return \Illuminate\Database\Eloquent\Model