Welcome Guest, Not a member yet? Register   Sign In
RESTful resource handling and delete: controller method not found
#1

(This post was last modified: 01-19-2022, 06:37 AM by Zeff.)

Hi all,
I created a controller User in a subfolder ('administration'): App/Controllers/Administration/User.php
Acording to https://codeigniter4.github.io/userguide...stful.html, I added a route (config\routes.php):
Code:
$routes->resource('administration/user', ['placeholder' => '(:num)']);

Within my User controller, I created the corresponding methods:

PHP Code:
<?php
namespace App\Controllers\Administration;

use 
App\Controllers\RootController;
use 
App\Models\Administration\UserModel;

class 
User extends RootController
{
    public function __construct() { parent::__construct(); }

    public function index() { ... show all users ...} // route for URI /administration/user/
    public function new() { ... }
    public function create() { ... }
    public function show(int $id) { ... }
    public function edit(int $id) { ... }
    public function update(int $id) { ... }
    public function delete(int $id) { ... }

The overview (index method), show user, edit, new,  methods all work except for the delete method.
URI requests to:
- http://localhost/administration/user/1/delete or
- http://localhost/administration/user/delete/1
result  in a '404 - File Not Found | Controller method is not found: user' error
So it seems that the URI is not correctly translated to the /administration/user controller; user is seen as method...  Sad
Can anyone help me with this weird issue?
Many thanks in advance!
Reply


Messages In This Thread
RESTful resource handling and delete: controller method not found - by Zeff - 01-19-2022, 06:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB