26 lines
781 B
PHP
26 lines
781 B
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
use Paymenter\Extensions\Others\NavbarManager\Models\NavbarLink;
|
|
|
|
Route::group(['prefix' => 'navbar'], function () {
|
|
Route::get('/redirect/{linkId}', function($linkId) {
|
|
try {
|
|
$link = NavbarLink::findOrFail($linkId);
|
|
if (!$link->is_active) {
|
|
abort(404);
|
|
}
|
|
|
|
if ($link->link_type === 'path' && $link->custom_path) {
|
|
return redirect($link->custom_path);
|
|
} elseif ($link->link_type === 'url' && $link->custom_url) {
|
|
return redirect($link->custom_url);
|
|
}
|
|
|
|
abort(404);
|
|
} catch (\Exception $e) {
|
|
abort(404);
|
|
}
|
|
})->name('navbar.redirect');
|
|
});
|