In this article, we will see laravel 8 eloquent orWhereHas() condition. So, I will give you a simple example of how to use orWherehas() condition with laravel eloquent relationship. You can also use with laravel 6, laravel 7, laravel 8 laravel 9

So, let's see laravel 8 orWhereHas() relationship or orwherehas condition in laravel 8.

Exit fullscreen mode app/Models/Country.php whereHas('country', function ($query) use($name){ $query->where('name', 'like', '%'.$name.'%'); }) ->orWhereHas('state', function ($query) use($name){ $query->where('name', 'like', '%'.$name.'%'); }) ->get() ->toArray(); }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners