offtaker access
This commit is contained in:
parent
a10828f460
commit
59160a62c3
@ -22,7 +22,9 @@ public function index(): JsonResponse
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
Gate::authorize('any',['super_admin', 'petani']);
|
||||
if (!Gate::any(['super_admin', 'petani', 'fasilitator', 'admin'])) {
|
||||
abort(403, 'Unauthorized');
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'user_email' => ['required', 'email', 'max:255'],
|
||||
@ -49,14 +51,18 @@ public function store(Request $request): JsonResponse
|
||||
|
||||
public function show(string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('any',['super_admin', 'petani']);
|
||||
if (!Gate::any(['super_admin', 'petani', 'fasilitator', 'admin'])) {
|
||||
abort(403, 'Unauthorized');
|
||||
}
|
||||
$offtaker = Offtaker::findOrFail($id);
|
||||
return response()->json($offtaker);
|
||||
}
|
||||
|
||||
public function update(Request $request, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('any',['super_admin', 'petani']);
|
||||
if (!Gate::any(['super_admin', 'petani', 'fasilitator', 'admin'])) {
|
||||
abort(403, 'Unauthorized');
|
||||
}
|
||||
$offtaker = Offtaker::findOrFail($id);
|
||||
|
||||
$validated = $request->validate([
|
||||
@ -74,7 +80,9 @@ public function update(Request $request, string $id): JsonResponse
|
||||
|
||||
public function destroy(string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('any',['super_admin', 'petani']);
|
||||
if (!Gate::any(['super_admin', 'petani', 'fasilitator', 'admin'])) {
|
||||
abort(403, 'Unauthorized');
|
||||
}
|
||||
Offtaker::findOrFail($id)->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
@ -85,7 +93,9 @@ public function destroy(string $id): JsonResponse
|
||||
*/
|
||||
public function batchUpsert(Request $request): JsonResponse
|
||||
{
|
||||
Gate::authorize('any',['super_admin', 'petani']);
|
||||
if (!Gate::any(['super_admin', 'petani', 'fasilitator', 'admin'])) {
|
||||
abort(403, 'Unauthorized');
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'offtakers' => ['required', 'array'],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user