# Controllers

# Naming convention

Generally controllers are named by the plural form of their corresponding resource and a Controller suffix. This is to avoid naming collisions with models that are often equally named.

Bad: UserController or User

Good: UsersController or EventsController

Action based, non-resourceful controllers should be named in singular form and again suffixed by Controller.

Bad: UserCleanup or UsersCleanupController

Good: UserCleanupController

# Action based, non-resourceful controllers

Action based, non-resourceful controllers always should be "invokable", they should contain any other public method

// Bad
class PerformCleanupController
{
    public function get()
    {
        //
    }
}

// Good
class PerformCleanupController
{
    public function __invoke()
    {
        //
    }
}

# Extending

Laravel by default always includes App\Http\Controllers\Controller base controller with some basic helper methods.

In most cases you don't need those helper methods, unless really necessary for shared functionality, try to avoid adding inheritance for controller classes.