vincent15000's avatar

append() and meta pagination data with API Resources

Hello,

When I add append() to load appended properties, I lose any meta pagination datas.

public function with($request)
{
    return [
        'meta' => [
            'can_create' => auth()->user()->can('create', Course::class),
        ],
    ];
}
...
new CourseCollection(Course::with('topic.unit', 'room')->where('training_id', $training->id)->orderByDesc('datetime')->paginate(20)->append(['start_date_fr', 'end_date_fr']))

Do you have any idea why ?

0 likes
1 reply
vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

For now I have set both needed appended attributes as permanent appended attributes and I have the pagination datas in the meta datas.

Please or to participate in this conversation.