server/src/app/Http/Controllers/Api/DocumentController.php
changeset 324 92fc9d077f95
parent 319 78990a8a069b
child 326 226d5b17a119
equal deleted inserted replaced
323:47f0611cc57d 324:92fc9d077f95
    23     /**
    23     /**
    24      * Display a listing of the resource.
    24      * Display a listing of the resource.
    25      *
    25      *
    26      * @return Response
    26      * @return Response
    27      */
    27      */
    28     public function index()
    28     public function index(Request $request)
    29     {
    29     {
    30         $paginator = $this->documentRepository->paginateAll();
    30         $perPage = intval($request->input('perpage', config('corpusparole.documents_per_page')));
       
    31         $paginator = $this->documentRepository->paginateAll($perPage);
    31         $res = $paginator->toArray();
    32         $res = $paginator->toArray();
    32         if(array_key_exists('data', $res)) {
    33         if(array_key_exists('data', $res)) {
    33             $documents = $res['data'];
    34             $documents = $res['data'];
    34             unset($res['data']);
    35             unset($res['data']);
    35             $res['documents'] = $documents;
    36         } else {
    36             //$res['documents'] = $this->documentRepository->resolveLexvo($documents);
    37             $documents = [];
    37         }
    38         }
    38         return response()->json($res);
    39         return response()->json([ 'documents' => $documents, 'meta' => $res]);
    39     }
    40     }
    40 
    41 
    41     /**
    42     /**
    42      * Show the form for creating a new resource.
    43      * Show the form for creating a new resource.
    43      *
    44      *