getNavigationBadge()
This function is not working for me, what could be the reason?
public static function getNavigationBadge(): ?string
{
return static::getModel()::where('stock_minimo','>','stock')->count();
}
Solution:Jump to solution
This is what you need
whereColumn
https://laravel.com/docs/11.x/queries#additional-where-clauses
```php
public static function getNavigationBadge(): ?string
{
return static::getModel()::whereColumn('stock_minimo', '<', 'stock')->count();...14 Replies
You’re using a greater than to compare two strings. ‘> stock’ doesn’t make sense.
return static::getModel()::where('stock_minimo','>',intval('stock'))->count();
Not working
Right but what is stock_minimo’s field type in the database. You’re code is saying to return records where ‘stock_minimo’ > ‘stock’, but ‘stock’ is a string and not mathematically comparable.
stock_minimo in database is integer
Great but ‘stock’ is a string in your code not an integer.
Seems like ‘stock’ should be a variable and not ‘stock’
OK. Thanks
Nice, you saw for yourself that doesn't work but returns more than one number 🙂
any ideas?
?
I want to control the products that are with minimum_stock, but the following function does not work for me
public static function getNavigationBadge(): ?string
{
return static::getModel()::where('stock_minimo','<','stock')->count();
}
Solution
You replied "Ok Thanks" to awcodes explanation. Didn't sound like you need further assistance 😅
Perfect Vp. Thanks