laravel wherehas

Posted by Paidboom - 2 months ago

laravel wherehas : How to use whereHas with orWhereHas in Laravel?

$products = Product::whereHas('types', function($q){
    $q->where('created_at', '>=', '2022-01-01 00:00:00');
})->get();
// only products that have types from 2022 on forward are returned