app\Category::scopeFull PHP Method

scopeFull() public method

scopeFull Retrieve the total of products contained in a category.
public scopeFull ( [type] $query ) : [type]
$query [type]
return [type]
    public function scopeFull($query)
    {
        return $query->where(\DB::raw(0), '<', function ($sql) {
            $sql->select(\DB::raw('COUNT(products.id)'))->from('products')->whereRaw('categories.id=products.category_id');
        });
    }