-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWikiController.php
More file actions
29 lines (23 loc) · 896 Bytes
/
WikiController.php
File metadata and controls
29 lines (23 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace App\Http\Controllers\Backend;
use App\Http\Controllers\Controller;
use App\Wiki;
use Illuminate\Http\Request;
class WikiController extends Controller {
public function getWikiForDomain(Request $request): \Illuminate\Http\JsonResponse {
$validated = $request->validate([
'domain' => 'required|string',
]);
$domain = $validated['domain'];
// XXX: this same logic is in quickstatements.php and platform api WikiController backend
try {
$wiki = Wiki::with(['wikiDb', 'wikiQueryserviceNamespace', 'settings'])->firstWhere('domain', $domain);
} catch (\Exception $e) {
return response()->json($e->getMessage(), 500);
}
if (!$wiki) {
return response()->json(['error' => 'Not found'], 404);
}
return response()->json(['data' => $wiki], 200);
}
}