Welcome Guest, Not a member yet? Register   Sign In
Resource Controller problem with show method and uri param

(This post was last modified: 05-05-2022, 10:30 AM by kabeza.)

I have the following route configured in app/Config/Routes.php

        'only' => ['index', 'show'],
        "controller" => "Api\Project"

Then I have the Project controller in app/Controllers/Api/Project.php

namespace App\Controllers\Api;
use CodeIgniter\RESTful\ResourceController;
class Project extends ResourceController
    protected $modelName = 'App\Models\ProjectModel';
    protected $format    = 'json';

    public function index()
        return $this->respond($this->model->findAll());

    public function show($id = null)
        return $this->respond($id);

When I run

I get all the records in json, all works fine

But when running this url

I get as output show and not 26 value.

What could be happening ?

How should I modify the route in case show method has more parameters?

Thanks a lot


I must have looked like an a*****e

For anyone having similar "issue" the correct url for show method in resourceController is


Because looking several times the way routes are generated, the show route is generated without the show word


Theme © iAndrew 2016 - Forum software by © MyBB