php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Pagination error

Open kmligue opened this issue 4 years ago • 2 comments
trafficstars

Anyone experience this error Fatal error: Uncaught Error: Call to a member function make() on null in vendor/illuminate/pagination/LengthAwarePaginator.php:91?

This is my sample code:

$cm = new \Webklex\PHPIMAP\ClientManager([]);
$client = $cm->make([
                'host'          => $imap_settings['host'],
                'port'          => $imap_settings['port'],
                'encryption'    => 'ssl',
                'validate_cert' => true,
                'username'      => $imap_settings['username'],
                'password'      => $imap_settings['password'],
                'protocol'      => 'imap'
]);
$client->connect();
$inbox = $client->getFolder('INBOX');

$messages = $inbox->messages();
$paginator = $messages->all()->paginate(5, 1);

$paginator->links() // This is where the error occur

kmligue avatar Sep 16 '21 07:09 kmligue

@kmligue Hi, I was looking for an answer to my question, and since I managed to make pagination I decided to throw you my way. I will be glad if I can help solve the problem.

$folders = $this->client->getFolders();
$folders[0]->messages()->setFetchOrderDesc()->limit($maxResult, $page)->all()->get();

By the way, there most likely first "paginate" and then "all" $messages->paginate($maxResult, $page)->all()

byhaskell avatar Oct 08 '21 02:10 byhaskell

Hi @kmligue , many thanks for your report. Can you provide any additional context such as the callstack? I'm currently unable to reproduce this issue.

Best regards,

Webklex avatar Oct 21 '21 00:10 Webklex