• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Routes with regex and namespace


I am having trouble defining my routes for my admin pages.

I have multiple Controllers in my app/Admin folder with Namespace App\Admin (including Dashboard and Order)

Here is an example Order.php :

PHP Code:
namespace App\Admin;
Order extends Controller{

What I wanted to achieve was :

PHP Code:
$routes->group('admin', ['namespace' => 'App\Admin'], function($routes)

to get the default index function of my \App\Admin\Order controller.

I did notice the $0, $1 ... syntax only works when there is at least one forward slash in front of my route "/([a-zA-Z_]+)" which I think is unfortunate.

I can easily show the Dashboard (example.com/admin) that is hardcoded but can't seem to get the Order controller (example.com/admin/Order or even example.com/admin/order) through the regex, although they are in the same namespace and folder.

It seems that you can use a lower case first letter when you want to get a controller through its filename, but when it comes to namespaces it's case sensitive or am I wrong?

I also tried

PHP Code:
$routes->group('admin', ['namespace' => 'App\Admin'], function($routes)


but alas it doesn't work either. I was hoping to use the group feature so that I can easily add other routes through regex like :
PHP Code:
$routes->get('([a-zA-Z_]+)/edit' '$1::edit' ); 


PHP Code:
$routes->get('([a-zA-Z_]+)/add' '$1::add' 

which doesn't seem too farfetched.

Any help resolving this issue would be greatly appreciated.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.