]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/TechniqueController.php
tech relations
[alttp.git] / app / Http / Controllers / TechniqueController.php
index a1ba20e59ac214877b46d815bcd6084d150a7df0..98623259f494f701e78a8fa3dedcd21da7350ccf 100644 (file)
@@ -12,10 +12,15 @@ class TechniqueController extends Controller
        public function search(Request $request) {
                $validatedData = $request->validate([
                        'phrase' => 'string|nullable',
+                       'type' => 'string|nullable',
                ]);
 
                $techs = Technique::where('index', '=', 1);
 
+               if (!empty($validatedData['type'])) {
+                       $techs = $techs->where('type', '=', $validatedData['type']);
+               }
+
                if (!empty($validatedData['phrase'])) {
                        $search = $validatedData['phrase'];
                        $techs = $techs->where(function (Builder $query) use ($search) {
@@ -29,7 +34,7 @@ class TechniqueController extends Controller
 
        public function single(Request $request, Technique $tech) {
                $this->authorize('view', $tech);
-               $tech->load('chapters');
+               $tech->load(['chapters', 'relations']);
                return $tech->toJson();
        }