Welcome Guest, Not a member yet? Register   Sign In
How can I get dynamic routes
#2

(This post was last modified: 11-27-2019, 01:16 PM by Michal_PB1.)

One idea which I have at the moment is: using code as below in /Config/Routes.php file:

PHP Code:
$db = \Config\Database::connect();
$paths $db->table('paths')->get()->getResult();

foreach (
$paths as $path)
{
    $routes->get($path->pathucfirst($path->controller).'Controller::show/'.$path->path);



I know that isn't a perfect solution but only one at the moment. Maybe someone has a better idea for this. I could also generate a file with generated all available paths and include in Routes.php (for better performance than reading all-time)
Reply


Messages In This Thread
How can I get dynamic routes - by Michal_PB1 - 11-25-2019, 11:51 AM
RE: How can I get dynamic routes - by Michal_PB1 - 11-27-2019, 01:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB