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

[Question] whereHas, has relationship ? #951

Closed
kocoten1992 opened this Issue Jun 14, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@kocoten1992

kocoten1992 commented Jun 14, 2017

Hi diesel,

I'm coming from Laravel web framework, in Laravel there is Eloquent ORM (https://laravel.com/docs/5.4/eloquent-relationships)

It have some kind of magic with method like whereHas has

To explain, laravel allow user to define relationship before it going to be use, and whereHas is something like this:

User::has('schools')->whereHas('bankAccount', function ($q) { // $q here is on bank now
    $q->where('balance', '>', '9999');
})->get();

// whereHas is a _where_ on a different table, _has_ is count on relationship have at least 1 record

Will feature like that gonna be implement in diesel in the future? Thank you for reading this.

@sgrif

This comment has been minimized.

Member

sgrif commented Jun 14, 2017

Our associations API is documented here. If you want to get all of the schools which have a bank account, just join between the two tables.

@sgrif sgrif closed this Jun 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment