access laravel pagination protected object property?

access laravel pagination protected object property?

In this post we will give you information about access laravel pagination protected object property?. Hear we will give you detail about access laravel pagination protected object property?And how to use it also give you demo for it if it is necessary.

Hello, everyone in this tutorials i will share with you something small but very helpful programing tricks, how to acces laravel pagination protected object property.


recently i was work one laravel application and i need to direct use laravel pagination protected object’s property. so, i also share with you.


First, here we show how to look like object get when we get values help of laravel pagination.


Step : 1 Get Data Help Of Pagination.




$getData = User::orderBy('created_at','desc')->paginate(5);
dd($getData)



Output




LengthAwarePaginator {#394 ▼
  #total: 4
  #lastPage: 1
  #items: Collection {#389 ▼
    #items: array:4 [▼
      0 => IpApprove {#390 ▶}
      1 => IpApprove {#391 ▶}
      2 => IpApprove {#392 ▶}
      3 => IpApprove {#393 ▶}
    ]
  }
  #perPage: 5
  #currentPage: 1
  #path: "http://localhost:8001/ipapprove"
  #query: []
  #fragment: null
  #pageName: "page"
  +onEachSide: 3
  #options: array:2 [▶]
}



Look, in the output. now how to access direct total protected property? you can not access like that. $getData->total


Now, the following example you can see how to handle this typee of situation and how to access any object’s protected property in laravel application.




$getData = User::orderBy('created_at','desc')->paginate(5);
$getData = json_en($getData);
$getData = json_De($getData);
// now you can access all the protected property like....
dd($getData->total);



i hope you like this helpful article.

Hope this and post will helped you for implement access laravel pagination protected object property?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs

For More Info See :: laravel And github