use App\Models\TechniqueMap;
use App\Models\TechniqueTranslation;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
class TechniqueController extends Controller
return $result->toJson();
}
+ public function web(Request $request, $type, $name) {
+ $tech = Technique::where('type', '=', $type)->where('name', '=', $name)->first();
+ if ($tech) {
+ return view('app')
+ ->with('title', $tech->getTranslatedProperty('title'))
+ ->with('description', $tech->getTranslatedProperty('short'));
+ }
+ $url_map = [
+ 'dungeon' => 'dungeons',
+ 'location' => 'locations',
+ 'mode' => 'modes',
+ 'ruleset' => 'rulesets',
+ 'tech' => 'tech',
+ ];
+ $tech = Technique::where('name', '=', $name)->whereIn('type', array_keys($url_map))->first();
+ if ($tech && isset($url_map[$tech->type])) {
+ return redirect('/'.$url_map[$tech->type].'/'.$tech->name);
+ }
+ throw new ModelNotFoundException();
+ }
+
private function applyLocalizedValues($validatedData, $content) {
foreach (['attribution', 'description', 'short', 'title'] as $name) {
if (isset($validatedData[$name])) {
use Illuminate\Foundation\Http\Kernel as HttpKernel;
-class Kernel extends HttpKernel
-{
- /**
- * The application's global HTTP middleware stack.
- *
- * These middleware are run during every request to your application.
- *
- * @var array<int, class-string|string>
- */
- protected $middleware = [
- // \App\Http\Middleware\TrustHosts::class,
- \App\Http\Middleware\TrustProxies::class,
- \Illuminate\Http\Middleware\HandleCors::class,
- \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
- \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
- \App\Http\Middleware\TrimStrings::class,
- // \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
- ];
+class Kernel extends HttpKernel {
- /**
- * The application's route middleware groups.
- *
- * @var array<string, array<int, class-string|string>>
- */
- protected $middlewareGroups = [
- 'web' => [
- \App\Http\Middleware\EncryptCookies::class,
- \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
- \Illuminate\Session\Middleware\StartSession::class,
- // \Illuminate\Session\Middleware\AuthenticateSession::class,
- \Illuminate\View\Middleware\ShareErrorsFromSession::class,
- \App\Http\Middleware\VerifyCsrfToken::class,
- \Illuminate\Routing\Middleware\SubstituteBindings::class,
- ],
+ /**
+ * The application's global HTTP middleware stack.
+ *
+ * These middleware are run during every request to your application.
+ *
+ * @var array<int, class-string|string>
+ */
+ protected $middleware = [
+ // \App\Http\Middleware\TrustHosts::class,
+ \App\Http\Middleware\TrustProxies::class,
+ \Illuminate\Http\Middleware\HandleCors::class,
+ \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
+ \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
+ \App\Http\Middleware\LanguageMiddleware::class,
+ \App\Http\Middleware\TrimStrings::class,
+ // \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+ ];
- 'api' => [
- \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
- 'throttle:api',
- \Illuminate\Routing\Middleware\SubstituteBindings::class,
- ],
- ];
+ /**
+ * The application's route middleware groups.
+ *
+ * @var array<string, array<int, class-string|string>>
+ */
+ protected $middlewareGroups = [
+ 'web' => [
+ \App\Http\Middleware\EncryptCookies::class,
+ \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
+ \Illuminate\Session\Middleware\StartSession::class,
+ // \Illuminate\Session\Middleware\AuthenticateSession::class,
+ \Illuminate\View\Middleware\ShareErrorsFromSession::class,
+ \App\Http\Middleware\VerifyCsrfToken::class,
+ \Illuminate\Routing\Middleware\SubstituteBindings::class,
+ ],
+
+ 'api' => [
+ \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
+ 'throttle:api',
+ \Illuminate\Routing\Middleware\SubstituteBindings::class,
+ ],
+ ];
+
+ /**
+ * The application's route middleware.
+ *
+ * These middleware may be assigned to groups or used individually.
+ *
+ * @var array<string, class-string|string>
+ */
+ protected $routeMiddleware = [
+ 'auth' => \App\Http\Middleware\Authenticate::class,
+ 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
+ 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
+ 'can' => \Illuminate\Auth\Middleware\Authorize::class,
+ 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+ 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
+ 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
+ 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
+ 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
+ ];
- /**
- * The application's route middleware.
- *
- * These middleware may be assigned to groups or used individually.
- *
- * @var array<string, class-string|string>
- */
- protected $routeMiddleware = [
- 'auth' => \App\Http\Middleware\Authenticate::class,
- 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
- 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
- 'can' => \Illuminate\Auth\Middleware\Authorize::class,
- 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
- 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
- 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
- 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
- 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
- ];
}
use App\Http\Controllers\DiscordController;
use App\Http\Controllers\SitemapXmlController;
+use App\Http\Controllers\TechniqueController;
+use App\Models\Event;
+use App\Models\Technique;
use Illuminate\Support\Facades\Route;
/*
Route::get('/sitemap.xml', [SitemapXmlController::class, 'index']);
+Route::get('/dungeons/{name}', function($name) {
+ return app()->call('App\Http\Controllers\TechniqueController@web', ['type' => 'dungeon', 'name' => $name]);
+});
+
+Route::get('/locations/{name}', function($name) {
+ return app()->call('App\Http\Controllers\TechniqueController@web', ['type' => 'location', 'name' => $name]);
+});
+
+Route::get('/modes/{name}', function($name) {
+ return app()->call('App\Http\Controllers\TechniqueController@web', ['type' => 'mode', 'name' => $name]);
+});
+
+Route::get('/rulesets/{name}', function($name) {
+ return app()->call('App\Http\Controllers\TechniqueController@web', ['type' => 'ruleset', 'name' => $name]);
+});
+
+Route::get('/tech/{name}', function($name) {
+ return app()->call('App\Http\Controllers\TechniqueController@web', ['type' => 'tech', 'name' => $name]);
+});
+
Route::view('/{path?}', 'app')->where('path', '.*');
Route::group(['prefix' => config('larascord.prefix'), 'middleware' => ['web']], function() {