hosamaldeen / auto_route
laravel General Route : to allow You not to put every general route in the route file
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:laravel
This package is not auto-updated.
Last update: 2025-02-06 05:12:55 UTC
README
laravel General Route to allow You not to put every general route in the route file
Installation
run this command composer require hosamaldeen/auto_route
Route Rules
there are 4 ways for general routes based on the count of the segments
-
Urls that include 1 segments like /product
will request ProductController@index -
Urls that include 2 segments /product/all
will request ProductController@all -
Urls that include 2 segments and the second segment is number like /product/1
will request ProductController@view
and pass the value to the function as {id} -
Urls that include 3 segments /product/search/1
will request ProductController@search
and pass the value to the function as {id}
Usage
in your route file add this
$defaultRoute = new HosamAldeen\AutoRoute\Route;
$defaultRoute->create();
you can add some options to your routes
$defaultRoute = new HosamAldeen\AutoRoute\Route;
$defaultRoute->prefix = '';
$defaultRoute->middleware = [];
$defaultRoute->namespace = '';
$defaultRoute->create();
Full Example
$defaultRoute = new HosamAldeen\AutoRoute\Route; // frontend
$defaultRoute->create();
$defaultRoute = new HosamAldeen\AutoRoute\Route; //backend
$defaultRoute->prefix = '/backend';
$defaultRoute->middleware = ['web'];
$defaultRoute->namespace = 'Backend';
$defaultRoute->create();