Skip to content

Commit bd345f1

Browse files
committed
Add redirects
1 parent 79a30f7 commit bd345f1

1 file changed

Lines changed: 45 additions & 12 deletions

File tree

src/routes/web.php

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,41 @@
1717
'prefix' => '/'.sharp()->config()->get('custom_url_segment'),
1818
'middleware' => ['sharp_common', 'sharp_web'],
1919
], function () {
20-
Route::get('/', [HomeController::class, 'index'])
21-
->name('code16.sharp.home');
22-
20+
// Redirect GET routes without filterKey
2321
Route::get('s-dashboard/{dashboardKey}', fn ($entityKey) => redirect(
24-
route('code16.sharp.dashboard', ['root', $entityKey])
22+
route('code16.sharp.dashboard', [
23+
sharp()->context()->globalFilterUrlSegmentValue(),
24+
$entityKey]
25+
)
26+
));
27+
Route::get('s-list/{entityKey}', fn ($entityKey) => redirect(
28+
route('code16.sharp.list', [
29+
sharp()->context()->globalFilterUrlSegmentValue(),
30+
$entityKey,
31+
])
32+
));
33+
Route::get('s-show/{entityKey}', fn ($entityKey) => redirect(
34+
route('code16.sharp.single-show', [
35+
sharp()->context()->globalFilterUrlSegmentValue(),
36+
$entityKey,
37+
])
2538
));
2639

40+
Route::get('/', [HomeController::class, 'index'])
41+
->name('code16.sharp.home');
42+
2743
Route::get('{filterKey}/s-dashboard/{dashboardKey}', [DashboardController::class, 'show'])
2844
->name('code16.sharp.dashboard');
2945

3046
Route::post('/s-dashboard/{dashboardKey}', [DashboardFiltersController::class, 'store'])
3147
->name('code16.sharp.dashboard.filters.store');
3248

33-
Route::get('s-list/{entityKey}', fn ($entityKey) => redirect(
34-
route('code16.sharp.list', ['root', $entityKey])
35-
));
36-
3749
Route::get('{filterKey}/s-list/{entityKey}', [EntityListController::class, 'show'])
3850
->name('code16.sharp.list');
3951

4052
Route::post('/s-list/{entityKey}/filters', [EntityListFiltersController::class, 'store'])
4153
->name('code16.sharp.list.filters.store');
4254

43-
Route::get('s-show/{entityKey}', fn ($entityKey) => redirect(
44-
route('code16.sharp.single-show', ['root', $entityKey])
45-
));
46-
4755
Route::get('{filterKey}/s-show/{entityKey}', [SingleShowController::class, 'show'])
4856
->name('code16.sharp.single-show');
4957

@@ -53,6 +61,31 @@
5361
Route::where([
5462
'parentUri' => '(s-list|s-show)/.+',
5563
])->group(function () {
64+
// Redirect GET routes without filterKey
65+
Route::get('{parentUri}/s-show/{entityKey}/{instanceId}', fn ($parentUri, $entityKey, $instanceId) => redirect(
66+
route('code16.sharp.show.show', [
67+
sharp()->context()->globalFilterUrlSegmentValue(),
68+
$parentUri,
69+
$entityKey,
70+
$instanceId,
71+
])
72+
));
73+
Route::get('{parentUri}/s-form/{entityKey}', fn ($parentUri, $entityKey) => redirect(
74+
route('code16.sharp.form.create', [
75+
sharp()->context()->globalFilterUrlSegmentValue(),
76+
$parentUri,
77+
$entityKey,
78+
])
79+
));
80+
Route::get('{parentUri}/s-form/{entityKey}/{instanceId}', fn ($parentUri, $entityKey, $instanceId) => redirect(
81+
route('code16.sharp.form.edit', [
82+
sharp()->context()->globalFilterUrlSegmentValue(),
83+
$parentUri,
84+
$entityKey,
85+
$instanceId,
86+
])
87+
));
88+
5689
Route::get('/{filterKey}/{parentUri}/s-show/{entityKey}/{instanceId}', [ShowController::class, 'show'])
5790
->name('code16.sharp.show.show');
5891

0 commit comments

Comments
 (0)