-1

Just upgraded to Laravel 10 and I found that the links in the meta response are not correctly populating with the expected string. I am using this package.

In the Laravel framework there is a class Illuminate\Pagination\LengthAwarePaginator that has a method link collection:

public function linkCollection()
{
    return collect($this->elements())->flatMap(function ($item) {
        if (! is_array($item)) {
            return [['url' => null, 'label' => '...', 'active' => false]];
        }

        return collect($item)->map(function ($url, $page) {
            return [
                'url' => $url,
                'label' => (string) $page,
                'active' => $this->currentPage() === $page,
            ];
        });
    })->prepend([
        'url' => $this->previousPageUrl(),
        'label' => function_exists('__') ? __('pagination.previous') : 'Previous',
        'active' => false,
    ])->push([
        'url' => $this->nextPageUrl(),
        'label' => function_exists('__') ? __('pagination.next') : 'Next',
        'active' => false,
    ]);
}

The problem is simple that the function_exists('__') is returning false and it is causing the label to be 'Previous' or 'Next'. This is a problem because my front end depends on the pagination.previous and pagination.next string in order to build the pagination tabs.

Any idea why this might be happening?

enter image description here

Kevin Pimentel
  • 2,056
  • 3
  • 22
  • 50
  • I would check if trans() exists at that point, maybe other helpers as well (like `route()` maybe) - to see if its a problem with being outside service container/without helpers introduced to scope -- somehow. (possible especially if the thing is used/debugged in a weird place. For example, can't use those in config files usually). Probably not this, but worth a shot. – wojand Aug 04 '23 at 19:27
  • btw hope you sure that function_exists evaluates to false. &laquo is intriguing me there. edit: Now that are think about it, you probably made sure that it is not using __ by adding the symbol. Intriguing problem you encounetred here. – wojand Aug 04 '23 at 19:29
  • 1
    now that I look at it even more, label being "pagination.previous" in the second image would probably indicate that __() function EXISTS, but the TRANSLATION is probably MISSING in app's main as well as fallback locale. I would really check again if __() does not exist. Don't be afraid of adding a log in the snippet you show (even if it's a vendor file - consider doing backup, or just do ctrl-z after all). – wojand Aug 04 '23 at 19:39
  • Turned out that they added a new default lang file for pagination.next and pagination.previous. SO it was finding something and returning it! – Kevin Pimentel Aug 04 '23 at 20:59

0 Answers0