Laravel Greater than or equal in views

2.9k Views Asked by At

I passed a variable to view and I want to make an if condition for this value with greater than or equal

example

@if($var >= 3)
do something...
@endif

when I do this I got this error

Object of class Illuminate\Database\Eloquent\Collection could not be converted to int

I search a lot about this but I didn't get any answers

1

There are 1 best solutions below

0
On

Assuming you want to compare the number of records. Then you can achieve the same as below

if ($var->count() >= 3){ }

if (count($var) >= 3) {}