Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

muazzamazaz's avatar

Unexpected T Double Arrow, expending , or )

 return Role::with('permissions:id,name,description')
            ->withCount('users')
            ->when($this->getFilter('search'), fn ($query, $term) => $query->search($term));
0 likes
1 reply
krs's avatar
krs
Best Answer
Level 17

Hi, don't we ask questions any more here in the forum :-)?

So let's start guessing... Perhaps it's your php version not understanding the fn syntax, have you tried to provide a closure this way:

return Role::with('permissions:id,name,description')
            ->withCount('users')
            ->when($this->getFilter('search'), function ($query, $term) {
                return $query->search($term);
            });

cheers krs

1 like

Please or to participate in this conversation.