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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners