CodeIgniter Forums
'if' method for routes service - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: 'if' method for routes service (/showthread.php?tid=77440)



'if' method for routes service - Ceo - 09-02-2020

I'm thinking of adding an 'if' method to the RoutesCollection class.

It would work like this:

$routes->if(true,function($routes){
     // blah...
});

....

Or restrict routes to logged in users(Myth:Auth)

$routes->if(logged_in(),function($routes){

});

A good idea?


RE: 'if' method for routes service - murad_ali - 09-03-2020

You can use filters for this