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) {
+ $view = view('app')
+ ->with('title', $tech->getTranslatedProperty('title'))
+ ->with('description', $tech->getTranslatedProperty('short'));
+ if ($tech->image) {
+ $view = $view->with('image', url($tech->image));
+ } else if ($tech->gif) {
+ $view = $view->with('image', url($tech->gif));
+ }
+ return $view;
+ }
+ $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])) {