I have a function where I query a table with SQL and the result I see it, it works fine but I need to count the number of records that table has and I get an error.
public function myFunction($data)
{
$data = DB::table('users')
->select('id', DB::raw('count(*) as total')) / también con: ->select(DB::raw('count(*) as total), ->select(DB::raw('count(id) as total)
->join('cities', 'users.city_id', "=", 'cities.id')
->join('provinces', 'cities.province_id', "=", 'provinces.id')
->where('code', $users)->get();
return view('users', compact('data'));
}
I try to show the information in the view with {{$ data- > total_count}} and it shows me the following error: Undefined property: stdClass :: $ total_count (View: C: \ xampp \ htdocs \ index.blade. php)