distribution alloed

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-29 13:30:13 +07:00
co-authored by Copilot
parent a88409c779
commit 45926a9639
@@ -13,7 +13,7 @@ class DistributionController extends Controller
{ {
public function index(): JsonResponse public function index(): JsonResponse
{ {
if (!Gate::any(['super_admin', 'petani','fasilitator'])) { if (!Gate::any(['super_admin', 'petani','fasilitator', 'offtaker'])) {
abort(403); abort(403);
} }
@@ -25,6 +25,11 @@ class DistributionController extends Controller
$query->where('farmer_id', $user->profile->id); $query->where('farmer_id', $user->profile->id);
} }
// Jika offtaker, filter hanya data yang ditugaskan kepadanya
if ($user->role === 'offtaker') {
$query->where('offtaker_id', $user->profile->id);
}
return response()->json($query->get()); return response()->json($query->get());
} }