suubcs's avatar

Laravel Json Pagination

Hello , i have a JSON DATA , that's have a structure like this

{
id: 1,
user_id: "1",
title: "MBxyo",
comment: "HBMpOirpUKCTLIJqRey0Om42XAtgh5",
date_message: "2017-03-18",
read: 0
},
{
id: 2,
user_id: "1",
title: "qsd",
comment: "qds",
date_message: "2017-03-18",
read: 0
},

In my ApiController i get this data and sent it to the view like this :

public function ShowFormationMessages()
    {
        //Here i get Data From the Api
        $data = file_get_contents('http://localhost:90/api/getMessages?key=MarouaneSH-api');
      
        return view('Admin.Formation.Messages',[
             "messages" => $data,
        ]);
    }

and in my View

@foreach(json_decode($messages,true) as $message)
                    <tr>
                        <td>  {{$message['id']}} </td>
                        <td> {{$message['title']}}</td>
                        <td> {{$message['comment']}}</td>
                    </tr>
                    <!--here Iwant to use pagination-->
 @endforeach

this display all message comming from the JSON file , please ho can i paginate this data ?

0 likes
1 reply

Please or to participate in this conversation.