I will give you very simple example of how to use wherehas condition with laravel eloquent relationship. you can also use with laravel 6, laravel 7, laravel 8 and laravel 9 version. Sometime we need to add where condition with relation table then you need to use wherehas() method. for example if you have users with country relation then you want to filter with country then you must have to use whereHas(). so here i will give you two way to add condition with relation model, one using whereHas and second using whereRelation().