CodeIgniter Forums
Additional access points on RESTful resource - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Additional access points on RESTful resource (/showthread.php?tid=82449)



Additional access points on RESTful resource - BettyRNorahDeniels - 07-11-2022

Hi
I am creating a RESTful API in Code Igniter 4.

The resource route provides routes for: index, show, create, update, delete.

Currently, index gets all items by ID. Show gets 1 item by ID.

How can I create another access point to get an item by its name instead of by the ID?

I will need to be able to search for items by name or ID.

Any ideas?


RE: Additional access points on RESTful resource - kenjis - 07-20-2022

Add a method for it in your controller.
Add a route for it.

I recommend you try the official tutorial.
https://codeigniter4.github.io/CodeIgniter4/tutorial/index.html