Level 104
You want a collection comprising Products and Users????
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How do i search for products or users with username, slug or email that have the vendor role?
$product = Product::where ( 'p_name', 'LIKE', '%' . $q . '%' )->with('user')->get()
OR User::whereHas(
'roles', function($q){
$q->where('name', 'Vendor');
}
)->get();
Please or to participate in this conversation.