uniqueginun's avatar

laravel LengthAwarePaginator with API Resource

Hello there. I have this issue in my Laravel 8 app. I created a UserResource which extends Illuminate\Http\Resources\Json\JsonResource class

public function toArray($request)
{
    return [
       'id' => $this->id,
       'department_id' => $this->department_id,
	];
}

in my controller when I do this I suppose to see pagination meta data like links and other stuff. but I don't.


public function index()
{
     $users = User::active()->paginate();
					
     return [
		'users' => UserResource::collection($users), 
        'items' => Item::all()
     ]; 						
}

all I see is a normal collection without pagination and meta data

0 likes
0 replies

Please or to participate in this conversation.