X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FHttp%2FControllers%2FTechniqueController.php;h=1d51aff846f6f48910be8ae82c0e5e0d5483838a;hb=e4e7cbc7e4944b08d74f5752de337ba7700367f4;hp=59559a94a1883edb46c50c7f71e33cd33f87b072;hpb=7c6716036321ba09846785720e81459aad55a323;p=alttp.git diff --git a/app/Http/Controllers/TechniqueController.php b/app/Http/Controllers/TechniqueController.php index 59559a9..1d51aff 100644 --- a/app/Http/Controllers/TechniqueController.php +++ b/app/Http/Controllers/TechniqueController.php @@ -6,6 +6,7 @@ use App\Models\Technique; 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 @@ -68,6 +69,27 @@ 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])) {