#wherehasandorWhereHasqueryinlaravel
Explore tagged Tumblr posts
Text
Laravel whereHas and orWhereHas Query Example
In this exercise, I will explain Laravel whereHas and orWhereHas query model, wherehas and orWhereHas query utilized in Laravel for relationships. In this way, here I will give you a model of how to utilize wherehas in Laravel, wherehas expressive in Laravel 8 work same as has() work. has() is to channel the choosing model dependent on a relationship. So it acts likewise to a typical WHERE condition. In the event that you basically use has(‘relation’) that suggests you just need to get the models that have no lesser amount of related model in this connection. whereHas() works essentially equivalent to has() yet permits you to determine extra channels for the connected model to check.
whereHas() Example - 1
$blogs = Blogs::whereHas('comments', function (Builder $query) { $query->where('content', 'like', 'code%'); })->get();
whereHas() Example - 2
$users = User::whereHas('posts', function($q){ $q->where('created_at', '>=', '2022-01-01 00:00:00'); })->get(); I hope you will like the content and it will help you to learn Laravel whereHas and orWhereHas Query Example If you like this content, do share. Read the full article
#howtousewherehasinlaravel#laravelwhereHasandorWhereHasqueryexample#wherehasandorWhereHasqueryinlaravel#wherehaseloquentlaravellaravelwherehasorwherehas#laravelEloquent
0 notes