Using lumen 5.2, I am setting up a GET action that can have resource queries:
GET /expedientes?param1=value1&..paramn=valuen
In my routing I have:
$app->get('expedientes', 'ExpedientesController@index');
In my controller:
class ExpedientesController extends Controller
public function index(Request $request){
if ($request->has('name')) {
return $request->input('name');
}
}
}
The error I obtain:
Declaration of App\Http\Controllers\ExpedientesController::index(Illuminate\Http\Request $request) should be compatible with App\Http\Controllers\Controller::index
The funny thing is, if I rename the controler to a name different from "index", like "indexa" (in both the controller and the routing file) everything works perfectly.
So my question is: Using the standard function name "index" for getting a list of resources, which is the proper way to access the request?
Thanks a lot, regards,
Possible solution #1:
I found out that lumen doesn't use the same controllers as laravel ( lumen: App\Http\Controllers\Controller class not found with fresh install ).
Using
use Laravel\Lumen\Routing\Controller as BaseController;
In the controller so it inherits from lumen's controller
class ExpedientesController extends BaseController
allows me to use a Request parameter in the index method.
But I wonder. Is this the proper way? Even if it is, what would be the way to do this in laravel?