jonjie
2 months ago
147
6
Laravel

How to remove data where the child table that has less than 1 value in Laravel 4

Posted 2 months ago by jonjie

I'm trying to remove all data in my query where if you less the 2 columns in its child table, if the result value is less than 1 then remove it. Please see my code below.

Parent::whereHas('Child', function($query){
  return $query->where('status', 2)->where(if ((column1 - column2) > 0) then return it);
});

Please ask me if this is not clear for you.

Please sign in or create an account to participate in this conversation.