0
votes

I am building a Laravel 4 application and I am trying to sort out where my admin controller functions should go.

eg my admin user view, edit and update functions.

Previously in my User controller, I would have

function getIndex()
{ 
    // Get method for normal users
}

function getAdminIndex()
{
    // Get method for admin users
}

I would then have in the routes /users -> getIndex() and /admin/users -> getAdminIndex()

however, is this ideal?

The reason is it makes my routes file quite large as I have to specify every route.

With things like Blog posts, and Products, should I have one controller for logged out / user access, and then a separate controller, in an admin folder for just the admin functions?

Is there some open source projects I can look at?

3

3 Answers

1
votes

You should separate your regular controllers from your admin controllers. It's a matter of personal preference how you do it: you can create folders inside your controllers folder, or maybe you could create –almost– independent modules with controllers on their own.

For the first option, take a look at this project:

For the second one, which is a bit more complex, you can get inspired from this post by Ryan Tablada:

I personally prefer this last one if the project is medium/large size, and the other one if it's a small project.

0
votes

You can also try Laravella, a CMS, CRUD, Bootstrap, Uploader etc. framework for Laravel.

https://github.com/laravella/laravella/releases

0
votes

If your project is small, then you can use Resource Controller.