Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel How to apply Eloquent where() to child in hasMany() relationship

$data = TheParent::whereHas('child', fn($q) => $q->where('column', 1))
    ->with(['child' => fn($q) => $q->where('column', 1)])
    ->get();
 
PREVIOUS NEXT
Tagged: #laravel #How #apply #Eloquent #child #relationship
ADD COMMENT
Topic
Name
4+8 =