You can assign a group of routes that uses a namespace like App\Http\Controllers\Admin. And you can create a namespace using the fluent routing API.
As we have discussed in Custom Namespace in Laravel, The namespace is defined as a class of elements in which each element has a unique name to the associated class. See the following syntax of Laravel custom namespace.
Route::namespace('Admin')->group(function () {
// Controllers Within The "App\Http\Controllers\Admin" Namespace
});
Macros are techniques to build little pieces of reusable logic that we can create and load anywhere in Laravel. You can create as many macros as you want for just about anything in Laravel.
The router in Laravel is macroable, which means if you have a group of routes that you need to provide via reusable groups of route definitions or package, you can define the macro in a service provider.
Let’s check out one by one steps to create and use Route Macros in Laravel.
#laravel #macros #programming