Voyager create multiple routes for same table

mm-mm

Jun 26th, 2019 01:37 PM

Hi Guys,

I want create two routes for same table, is possibile ?

syedreza

Aug 1st, 2022 09:58 AM

Yes, it's possible. Inside vendor\tcg\voyager\routes\voyager.php after event(new RoutingAdmin()); add another route. For same table you need to create a new controller also resources. You can do this by copying vendor\tcg\voyager\src\Http\Controllers\VoyagerBaseController.php to new controller TableNameNewController and for resource copy vendor\tcg\voyager\resources\views\bread blade files inside resources\views\vendor\voyager(Folder Name). For New Controller:

  1. Make sure to change the namespace App\Http\Controllers and class name TableNameNewController after duplicate the VoyagerBaseController.
  2. Change the slug to $slug = '(Table Name)';
  3. Also $view = 'voyager::(Folder Name).browse';

For Resources:

  1. Create folder called vendor inside resources\views
  2. Inside vendor create another folder called voyager
  3. After that copy vendor\tcg\voyager\resources\views\bread folder inside resources\views\vendor\voyager and rename (Folder Name)

For Route:

  1. Inside vendor\tcg\voyager\routes\voyager.php after event(new RoutingAdmin()); add new routes. For example: Route::get('tableNameNew', ['uses' =>'App\Http\Controllers\TableNameNewController@index', 'as' => 'index']);

*If you add new function in the controller you need to make changes in the blade files or you can add action buttons. For more watch https://voyager.devdojo.com/academy/