3 months ago

How to get Count values in Laravel from Database?

Posted 3 months ago by sumitgroup

I am trying to display the total property from my database, All total property counting good, but the main issue is with Category wise. There are a column in my database lis_type and there are two category stored rent and sale, now i want to count sale and rent property. But i am getting error in counting.

ERROR Display: count(): Parameter must be an array or an object that implements Countable

Here are my code...

     public function index()
   $listing=Listing::orderBy('created_at', 'desc')->get();
   return view('listings.index', compact('listing'));

View Code:

   <button type="button" class="btn btn-danger btn-labeled-right rounded">
                            {{count($listing)}} &nbsp; Total Property
<button type="button" class="btn btn-success btn-labeled-right rounded">
                            {{count($listing->lis_type="sale")}} &nbsp; Sale
<button type="button" class="btn btn-info btn-labeled-right rounded">
                            {{count($listing->lis_type="rent")}} &nbsp;   Rent

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