shadkamel's avatar

makeVisible() with paginate()

hello every one, i have a problem with using makeVisible() with paginate() functions in one query, i want to retrieve a hidden property with the makeVisible function, but when is use makeVisible(), the pagination details will be lose, for example: current_page, next_url_page, ... please suggest a solution for me.

here is an example of my query:

$questions = Quizes::paginate(20);
 return $questions->makeVisible(['correct_answer'])->toArray();
0 likes
5 replies
shadkamel's avatar

@Sinnbeck i worked for me thank you a lot, but can you tell me more about that api resources that you mentioned ?

boogiefromzk's avatar

Here is an example:

$questions = Quizes::paginate(20);
return $questions
  ->through(fn($entity) => 
      $entity
          ->makeVisible('correct_answer')
  );
1 like

Please or to participate in this conversation.