CodeIgniter Forums
routes with namespace & filter not work proper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: routes with namespace & filter not work proper (/showthread.php?tid=79602)



routes with namespace & filter not work proper - [email protected] - 07-06-2021

Code:
$routes->get("dashboard", "DashboardController::index", ["namespace" => "\Modules\dashboard\Controllers\Admin"], ["filter" => "auth"]);

In the Above route namespace is work and filter is not work.
Code:
$routes->get("dashboard", "DashboardController::index", ["filter" => "auth"], ["namespace" => "\Modules\dashboard\Controllers\Admin"]);

In the Above route filter is work and namespace is not work.


I want both namespace & filter then what is the issue in above routes?



RE: routes with namespace & filter not work proper - ikesela - 07-07-2021

try use kint to trace the error , d(), dd(), trace()


RE: routes with namespace & filter not work proper - salain - 07-07-2021

Not 100% sure, but as far as I understand the documentation your filter and namespace options should be an array

PHP Code:
$routes->get("dashboard""DashboardController::index", ["namespace" => "\Modules\dashboard\Controllers\Admin","filter" => "auth"]); 



RE: routes with namespace & filter not work proper - InsiteFX - 07-07-2021

The last parameter to the routes is an $options array this is an associated array to hold all options to the route,
like namespace and filter

[namespace => name, filter => your_filter]


RE: routes with namespace & filter not work proper - [email protected] - 07-08-2021

(07-07-2021, 12:11 AM)salain Wrote: Not 100% sure, but as far as I understand the documentation your filter and namespace options should be an array

PHP Code:
$routes->get("dashboard""DashboardController::index", ["namespace" => "\Modules\dashboard\Controllers\Admin","filter" => "auth"]); 

Now, It's working. 
Thank You

(07-07-2021, 01:59 AM)InsiteFX Wrote: The last parameter to the routes is an $options array this is an associated array to hold all options to the route,
like namespace and filter

[namespace => name, filter => your_filter]

Now, It's working. 
Thank You