Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get ordered resultset in child repository? #32

Closed
appkr opened this issue Jun 15, 2015 · 1 comment
Closed

How can I get ordered resultset in child repository? #32

appkr opened this issue Jun 15, 2015 · 1 comment

Comments

@appkr
Copy link

appkr commented Jun 15, 2015

In my child repository...

class ChildRepository extends \Bosnadev\Repositories\Eloquent\Repository
{
    public function model() {}

    public function suggest($column, $search)
    {
        return $this->getByCriteria(new Like($column, $search))
            ->all(['id', \DB::raw("{$column} as name")]);
    }
}

all() returns EloquentCollection, and does not allow additional method chaining.

Before extending this package it was,

    public function suggest($column, $query)
    {
        return $this->model->where($column, 'like', $query . '%')
            ->orderBy($column, 'asc')->get(['id', \DB::raw("{$column} as name")]);
    }

What is the best way I can chain orderBy() with \Bosnadev\Repositories\Eloquent\Repository. Do I have to make a OrderBy Criteria?

@fer-ri
Copy link

fer-ri commented Aug 3, 2015

Maybe put your suggest into new Criteria

@appkr appkr closed this as completed Jan 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants