📕
Sprnva Docs
  • Introduction
  • What's New?
  • Installation
    • Requirements
    • Download Sprnva zip no composer required
    • Install Sprnva Using Composer
    • Setup Config
  • Deployment
  • File Structure
  • Database
    • Select
    • SelectLoop
    • Insert
    • Update
    • Delete
    • Query
    • Seeder
    • Paginate
    • With
    • andFilter
    • withCount
    • get
  • Query Builder
  • Migration
    • INSTANCES
      • NEW
      • RENAMETABLE
      • DROP
      • CHANGE
    • DUMPS
      • dump
      • dump prune
    • MAKE
    • MIGRATE
      • migrate
      • migrate fresh
    • ROLLBACK
  • Routing
    • with parameter
    • multiple parameters
    • with closure
    • group
    • controller grouping
  • Controllers
    • methods
  • Views
    • Passing Parameters
  • Validation
    • validate
      • validation type
  • Authentication
  • Alert Messages
  • Default Helpers
  • CSRF Protection
  • Email
  • Packages
    • Fortify
  • Themes and Templates
Powered by GitBook
On this page
  1. Routing

controller grouping

If a group of routes all utilize the same controller, you may use the controller method to define the common controller for all of the routes within the group. Then, when defining the routes, you only need to provide the controller method that they invoke.

Route::controller($param, $action);

// grouping the common controller
// dont write same controller repeatedly
Route::controller(['WelcomeController'], function () {
		
    // you can set the controller method as string
    Route::get('/settings', 'settings');
	
    // you can also set the controller method as array
    Route::get('/settings/add', ['create']);
    
    // you can also add middleware auth to a grouped controller
    // if there's no global middleware set in the parent
    Route::get('/settings/add', ['create', ['auth']]);

});
PreviousgroupNextControllers

Last updated 2 years ago