Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
22 / 22 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| RolePlayObjectionsController | |
100.00% |
22 / 22 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| index | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| store | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| show | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| update | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| destroy | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Controllers\v2\RolePlay; |
| 4 | |
| 5 | use App\Http\Controllers\Controller; |
| 6 | use App\Http\Models\RolePlayObjections; |
| 7 | use App\Http\Requests\v2\RolePlay\DestroyRolePlayObjectionsRequest; |
| 8 | use App\Http\Requests\v2\RolePlay\StoreRolePlayObjectionsRequest; |
| 9 | use App\Http\Requests\v2\RolePlay\UpdateRolePlayObjectionsRequest; |
| 10 | use Illuminate\Http\JsonResponse; |
| 11 | use Illuminate\Http\Request; |
| 12 | |
| 13 | class RolePlayObjectionsController extends Controller |
| 14 | { |
| 15 | public function index() |
| 16 | { |
| 17 | return response()->json([ |
| 18 | 'status' => 'success', |
| 19 | 'data' => RolePlayObjections::where('status', 'active')->get(), |
| 20 | ]); |
| 21 | } |
| 22 | |
| 23 | public function store(StoreRolePlayObjectionsRequest $request) |
| 24 | { |
| 25 | return response()->json([ |
| 26 | 'status' => 'success', |
| 27 | 'data' => RolePlayObjections::create($request->validated()), |
| 28 | ], 201); |
| 29 | } |
| 30 | |
| 31 | public function show(Request $request, RolePlayObjections $objection): JsonResponse |
| 32 | { |
| 33 | return response()->json([ |
| 34 | 'status' => 'success', |
| 35 | 'data' => $objection, |
| 36 | ]); |
| 37 | } |
| 38 | |
| 39 | public function update(UpdateRolePlayObjectionsRequest $request, RolePlayObjections $objection): JsonResponse |
| 40 | { |
| 41 | $objection->update($request->validated()); |
| 42 | |
| 43 | return response()->json([ |
| 44 | 'status' => 'success', |
| 45 | 'data' => $objection, |
| 46 | ]); |
| 47 | } |
| 48 | |
| 49 | public function destroy(DestroyRolePlayObjectionsRequest $request, RolePlayObjections $objection) |
| 50 | { |
| 51 | $objection->delete(); |
| 52 | |
| 53 | return response()->json([ |
| 54 | 'status' => 'success', |
| 55 | 'data' => null, |
| 56 | ]); |
| 57 | } |
| 58 | } |