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

[Request] Making eloquent has() accept conditions #1166

Closed
crissi opened this issue May 4, 2013 · 6 comments
Closed

[Request] Making eloquent has() accept conditions #1166

crissi opened this issue May 4, 2013 · 6 comments

Comments

@crissi
Copy link
Contributor

crissi commented May 4, 2013

$users = User::has(array('posts' => function($query)
{
$query->where('created_at', '>', '2012-04-05');
}))->get();

This would make the has() function so more powerful:-)

@PhiloNL
Copy link
Contributor

PhiloNL commented May 13, 2013

👍

I'm currently using belongsToMany relation to attach tags to specific project.
This would be very helpful to build a search filter for example:

$keywords = ['laravel', 'php', 'developer'];
$projects = $category->projects()->has(array('tags' => function($query) use ($keywords) {
   $query->whereIn('name', $keywords);
}));

@PhiloNL
Copy link
Contributor

PhiloNL commented May 13, 2013

Or maybe allow this to be set when defining a eager load constraint:

$projects = $category->projects()->with(array('tags' => function($query) use ($keywords) {
   $query->whereIn('name', $keywords);
   $query->has('>=', 1);
}));

tomsseisums added a commit to tomsseisums/framework that referenced this issue Jul 26, 2013
@taylorotwell
Copy link
Member

Closing for #1166.

@PhiloNL
Copy link
Contributor

PhiloNL commented Jul 30, 2013

Is this going to be added to 4.0.x?
Thanks!

@russback
Copy link

russback commented Aug 9, 2013

Any news on when this will be added into a 4.0.* release? It was closed 11 days ago and 4.0.6 was released 7 days ago, so I guess it was missed?

@dyatlov
Copy link

dyatlov commented Dec 5, 2013

Guys, please add this.. really need it

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

5 participants