Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel11 routes #5883

Open
wants to merge 2 commits into
base: 1.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 63 additions & 56 deletions routes/voyager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use TCG\Voyager\Events\Routing;
use TCG\Voyager\Events\RoutingAdmin;
Expand All @@ -20,37 +21,38 @@
Route::group(['as' => 'voyager.'], function () {
event(new Routing());

$namespacePrefix = '\\'.config('voyager.controllers.namespace').'\\';
$namespacePrefix = config('voyager.controllers.namespace');

Route::get('login', ['uses' => $namespacePrefix.'VoyagerAuthController@login', 'as' => 'login']);
Route::post('login', ['uses' => $namespacePrefix.'VoyagerAuthController@postLogin', 'as' => 'postlogin']);
Route::get('login', [$namespacePrefix . '\VoyagerAuthController', 'login'])->name('login');
Route::post('login', [$namespacePrefix . '\VoyagerAuthController', 'postLogin'])->name('postlogin');

Route::group(['middleware' => 'admin.user'], function () use ($namespacePrefix) {
event(new RoutingAdmin());

// Main Admin and Logout Route
Route::get('/', ['uses' => $namespacePrefix.'VoyagerController@index', 'as' => 'dashboard']);
Route::post('logout', ['uses' => $namespacePrefix.'VoyagerController@logout', 'as' => 'logout']);
Route::post('upload', ['uses' => $namespacePrefix.'VoyagerController@upload', 'as' => 'upload']);
Route::get('/', [$namespacePrefix . '\VoyagerController', 'index'])->name('dashboard');
Route::post('logout', [$namespacePrefix . '\VoyagerController', 'logout'])->name('logout');
Route::post('upload', [$namespacePrefix . '\VoyagerController', 'upload'])->name('upload');

Route::get('profile', ['uses' => $namespacePrefix.'VoyagerUserController@profile', 'as' => 'profile']);
Route::get('profile', [$namespacePrefix . '\VoyagerUserController', 'profile'])->name('profile');

try {
foreach (Voyager::model('DataType')::all() as $dataType) {
$breadController = $dataType->controller
? Str::start($dataType->controller, '\\')
: $namespacePrefix.'VoyagerBaseController';

Route::get($dataType->slug.'/order', $breadController.'@order')->name($dataType->slug.'.order');
Route::post($dataType->slug.'/action', $breadController.'@action')->name($dataType->slug.'.action');
Route::post($dataType->slug.'/order', $breadController.'@update_order')->name($dataType->slug.'.update_order');
Route::get($dataType->slug.'/{id}/restore', $breadController.'@restore')->name($dataType->slug.'.restore');
Route::get($dataType->slug.'/relation', $breadController.'@relation')->name($dataType->slug.'.relation');
Route::post($dataType->slug.'/remove', $breadController.'@remove_media')->name($dataType->slug.'.media.remove');
Route::resource($dataType->slug, $breadController, ['parameters' => [$dataType->slug => 'id']]);
? Str::start($dataType->controller, '\\')
: $namespacePrefix . '\VoyagerBaseController';
$commanSlug = $dataType->slug;
Route::get($commanSlug . '/order', [$namespacePrefix . $breadController, 'order'])->name($commanSlug . '.order');
Route::post($commanSlug . '/action', [$namespacePrefix . $breadController, 'action'])->name($commanSlug . '.action');
Route::post($commanSlug . '/order', [$namespacePrefix . $breadController, 'update_order'])->name($commanSlug . '.update_order');
Route::get($commanSlug . '/{id}/restore', [$namespacePrefix . $breadController, 'restore'])->name($commanSlug . '.restore');
Route::get($commanSlug . '/relation', [$namespacePrefix . $breadController, 'relation'])->name($commanSlug . '.relation');
Route::post($commanSlug . '/remove', [$namespacePrefix . $breadController, 'remove_media'])->name($commanSlug . '.media.remove');

Route::resource($commanSlug, $breadController)->parameters([$commanSlug => 'id']);
}
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException("Custom routes hasn't been configured because: ".$e->getMessage(), 1);
throw new \InvalidArgumentException("Custom routes hasn't been configured because: " . $e->getMessage(), 1);
} catch (\Exception $e) {
// do nothing, might just be because table not yet migrated.
}
Expand All @@ -59,81 +61,86 @@
Route::group([
'as' => 'menus.',
'prefix' => 'menus/{menu}',
], function () use ($namespacePrefix) {
Route::get('builder', ['uses' => $namespacePrefix.'VoyagerMenuController@builder', 'as' => 'builder']);
Route::post('order', ['uses' => $namespacePrefix.'VoyagerMenuController@order_item', 'as' => 'order_item']);
'controller' => $namespacePrefix . '\VoyagerMenuController',
], function () {
Route::get('builder', 'builder')->name('builder');
Route::post('order', 'order_item')->name('order_item');

Route::group([
'as' => 'item.',
'prefix' => 'item',
], function () use ($namespacePrefix) {
Route::delete('{id}', ['uses' => $namespacePrefix.'VoyagerMenuController@delete_menu', 'as' => 'destroy']);
Route::post('/', ['uses' => $namespacePrefix.'VoyagerMenuController@add_item', 'as' => 'add']);
Route::put('/', ['uses' => $namespacePrefix.'VoyagerMenuController@update_item', 'as' => 'update']);
], function () {
Route::delete('{id}', 'delete_menu')->name('destroy');
Route::post('/', 'add_item')->name('add');
Route::put('/', 'update_item')->name('update');
});
});

// Settings
Route::group([
'as' => 'settings.',
'prefix' => 'settings',
], function () use ($namespacePrefix) {
Route::get('/', ['uses' => $namespacePrefix.'VoyagerSettingsController@index', 'as' => 'index']);
Route::post('/', ['uses' => $namespacePrefix.'VoyagerSettingsController@store', 'as' => 'store']);
Route::put('/', ['uses' => $namespacePrefix.'VoyagerSettingsController@update', 'as' => 'update']);
Route::delete('{id}', ['uses' => $namespacePrefix.'VoyagerSettingsController@delete', 'as' => 'delete']);
Route::get('{id}/move_up', ['uses' => $namespacePrefix.'VoyagerSettingsController@move_up', 'as' => 'move_up']);
Route::get('{id}/move_down', ['uses' => $namespacePrefix.'VoyagerSettingsController@move_down', 'as' => 'move_down']);
Route::put('{id}/delete_value', ['uses' => $namespacePrefix.'VoyagerSettingsController@delete_value', 'as' => 'delete_value']);
'controller' => $namespacePrefix . '\VoyagerSettingsController',
], function () {
Route::get('/', 'index')->name('index');
Route::post('/', 'store')->name('store');
Route::put('/', 'update')->name('update');
Route::delete('{id}', 'delete')->name('delete');
Route::get('{id}/move_up', 'move_up')->name('move_up');
Route::get('{id}/move_down', 'move_down')->name('move_down');
Route::put('{id}/delete_value', 'delete_value')->name('delete_value');
});

// Admin Media
Route::group([
'as' => 'media.',
'prefix' => 'media',
], function () use ($namespacePrefix) {
Route::get('/', ['uses' => $namespacePrefix.'VoyagerMediaController@index', 'as' => 'index']);
Route::post('files', ['uses' => $namespacePrefix.'VoyagerMediaController@files', 'as' => 'files']);
Route::post('new_folder', ['uses' => $namespacePrefix.'VoyagerMediaController@new_folder', 'as' => 'new_folder']);
Route::post('delete_file_folder', ['uses' => $namespacePrefix.'VoyagerMediaController@delete', 'as' => 'delete']);
Route::post('move_file', ['uses' => $namespacePrefix.'VoyagerMediaController@move', 'as' => 'move']);
Route::post('rename_file', ['uses' => $namespacePrefix.'VoyagerMediaController@rename', 'as' => 'rename']);
Route::post('upload', ['uses' => $namespacePrefix.'VoyagerMediaController@upload', 'as' => 'upload']);
Route::post('crop', ['uses' => $namespacePrefix.'VoyagerMediaController@crop', 'as' => 'crop']);
'controller' => $namespacePrefix . '\VoyagerMediaController',
], function () {
Route::get('/', 'index')->name('index');
Route::post('files', 'files')->name('files');
Route::post('new_folder', 'new_folder')->name('new_folder');
Route::post('delete_file_folder', 'delete')->name('delete');
Route::post('move_file', 'move')->name('move');
Route::post('rename_file', 'rename')->name('rename');
Route::post('upload', 'upload')->name('upload');
Route::post('crop', 'crop')->name('crop');
});

// BREAD Routes
Route::group([
'as' => 'bread.',
'prefix' => 'bread',
], function () use ($namespacePrefix) {
Route::get('/', ['uses' => $namespacePrefix.'VoyagerBreadController@index', 'as' => 'index']);
Route::get('{table}/create', ['uses' => $namespacePrefix.'VoyagerBreadController@create', 'as' => 'create']);
Route::post('/', ['uses' => $namespacePrefix.'VoyagerBreadController@store', 'as' => 'store']);
Route::get('{table}/edit', ['uses' => $namespacePrefix.'VoyagerBreadController@edit', 'as' => 'edit']);
Route::put('{id}', ['uses' => $namespacePrefix.'VoyagerBreadController@update', 'as' => 'update']);
Route::delete('{id}', ['uses' => $namespacePrefix.'VoyagerBreadController@destroy', 'as' => 'delete']);
Route::post('relationship', ['uses' => $namespacePrefix.'VoyagerBreadController@addRelationship', 'as' => 'relationship']);
Route::get('delete_relationship/{id}', ['uses' => $namespacePrefix.'VoyagerBreadController@deleteRelationship', 'as' => 'delete_relationship']);
'controller' => $namespacePrefix . '\VoyagerBreadController',
], function () {
Route::get('/', 'index')->name('index');
Route::get('{table}/create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::get('{table}/edit', 'edit')->name('edit');
Route::put('{id}', 'update')->name('update');
Route::delete('{id}', 'destroy')->name('delete');
Route::post('relationship', 'addRelationship')->name('relationship');
Route::get('delete_relationship/{id}', 'deleteRelationship')->name('delete_relationship');
});

// Database Routes
Route::resource('database', $namespacePrefix.'VoyagerDatabaseController');
Route::resource('database', $namespacePrefix . '\VoyagerDatabaseController');

// Compass Routes
Route::group([
'as' => 'compass.',
'prefix' => 'compass',
], function () use ($namespacePrefix) {
Route::get('/', ['uses' => $namespacePrefix.'VoyagerCompassController@index', 'as' => 'index']);
Route::post('/', ['uses' => $namespacePrefix.'VoyagerCompassController@index', 'as' => 'post']);
'controller' => $namespacePrefix . '\VoyagerCompassController',
], function () {
Route::get('/', 'index')->name('index');
Route::post('/', 'index')->name('post');
});

event(new RoutingAdminAfter());
});

//Asset Routes
Route::get('voyager-assets', ['uses' => $namespacePrefix.'VoyagerController@assets', 'as' => 'voyager_assets']);
Route::get('voyager-assets', [$namespacePrefix . '\VoyagerController', 'assets'])->name('voyager_assets');

event(new RoutingAfter());
});
Loading