How to Access Laravel Pagination Protected Property
In this laravel error solving tutorial, I will show you how to solve cannot access protected property Illuminate\Pagination\LengthAwarePaginator::$total. You know that, we can not access this protected property like that.
To access this property, you have to follow the below tricks. See the example:
$data = User::orderBy('created_at','desc')->paginate(5); $data = json_encode($data); $data = json_Decode($data); // now you can access all the protected property like.... dd($data->total);
Read also: Laravel 9 Autocomplete Search Example with Typeahead
Hope it can help you.