sunny_jay_jay's avatar

Lumen - inconsistent behaviour with GET request

For an API I am writing, in my routes file I have:

$app->get('item/{id}', 'ApiController@item');
$app->get('groupitems/{group}', 'ApiController@groupItems');

In my Controller I have the relevant two functions:

public function item($id, Request $request)
{
    if ($this->isAuthorised($request->input('tenant_id'), $request->input('api_code'))) {
        $item = Line::find($id);
        if ($item) { ...

public function groupItems($id, Request $request)
{
    if ($this->isAuthorised($request->input('tenant_id'), $request->input('api_code'))) {
        $items = Line::where('tenant_id', $request->input('tenant_id'))->where('publish', true) ...

The calls are both made in exactly the same way, for example:

http://api.artlook.com/groupitems/29?tenant_id=2&api_code=o9rty43

Please don't try that as the URL is only on a local server at the moment.

My first function runs perfectly. The second one returns an error exception

Argument 2 passed to groupItems() must be an instance of Illuminate\Http\Request, string given

But they are identical and in the same controller. Help?

0 likes
1 reply
MarkLL's avatar
MarkLL
Best Answer
Level 7

Hi @sunny_jay_jay try changing ... public function groupItems($id, Request $request) to public function groupItems($group, Request $request) or change the definition in you route file for your groupitems route to use $id instead of $group

right now there is a mismatch...

1 like

Please or to participate in this conversation.