Pretty sure that's not a laravel problem but simply php.
What you say in your first line is "Assign the value 100 to the variable completed and then count that variable" which will work since it will always be 1. The second line says "see if completed is smaller than 100 and then count the boolean value that this produces". Also completed is not the collection.
What you need is something like this:
"filter $tasks to only get tasks with completed == true and count those".
Should be something like
{{ count($tasks->where("completed", true)) }}
Uhm... first of all thx for your help. But in my db the 'completed' column is integer (tasks table). It report the working status of the task from 0% to 100% and I need to show something like:
Completed (2) / In progress (5)
Ah, now I get it.
{{ $tasks->where("completed", 100)->count() }}
That should give you the completed ones.
{{ $tasks->filter(function ($item) { return $item->completed < 100;})->count() }}
That should give you the In progress ones. I took that from the laravel 5.1 documentation, I hope those methods already exist in 5.0. http://laravel.com/docs/5.1/collections
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community