-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathDomainController.php
More file actions
55 lines (39 loc) · 1.29 KB
/
DomainController.php
File metadata and controls
55 lines (39 loc) · 1.29 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Models\Domain;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
class DomainController extends Controller
{
public function index()
{
abort_if(!Auth::User()->isAPI(), Response::HTTP_FORBIDDEN, '403 Forbidden');
$domains = Domain::all();
return response()->json($domains);
}
public function store(Request $request)
{
abort_if(!Auth::User()->isAPI(), Response::HTTP_FORBIDDEN, '403 Forbidden');
$domain = Domain::create($request->all());
return response()->json($domain, 201);
}
public function show(Domain $domain)
{
abort_if(!Auth::User()->isAPI(), Response::HTTP_FORBIDDEN, '403 Forbidden');
return response()->json($domain);
}
public function update(Request $request, Domain $domain)
{
abort_if(!Auth::User()->isAPI(), Response::HTTP_FORBIDDEN, '403 Forbidden');
$domain->update($request->all());
return response()->json();
}
public function destroy(Domain $domain)
{
abort_if(!Auth::User()->isAPI(), Response::HTTP_FORBIDDEN, '403 Forbidden');
$domain->delete();
return response()->json();
}
}