Welcome Guest, Not a member yet? Register   Sign In
Routing Issue: Optional ID and Named Routes in CodeIgniter 4
#3

Thank you for the tip!
I’ve implemented something similar to your suggestion for generating URLs:

PHP Code:
public function getUrl(): string
{
    if (empty($this->id)) {
        return url_to('PostController::edit');
    }
    return url_to('PostController::edit'$this->id);


However, my question is more about understanding the strange behavior I encountered, rather than finding a solution Smile

It’s odd that adding a name to the route changes its behavior Undecided
Reply


Messages In This Thread
RE: Routing Issue: Optional ID and Named Routes in CodeIgniter 4 - by Elias - 03-26-2025, 12:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB