lainiii
This commit is contained in:
@@ -12,12 +12,15 @@ use App\Models\Map\Panen;
|
||||
|
||||
class PanenController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
Gate::authorize(['petani', 'fasilitator']);
|
||||
|
||||
$user = Auth::user();
|
||||
$listPanen = Panen::where('farmer_id', $user->profile->id)->get();
|
||||
$profile = $user->profile;
|
||||
|
||||
$profileId = $user->role === 'petani' ? $profile->id : $user->id;
|
||||
$listPanen = Panen::when($profileId, fn($q,$v) => $q->where('farmer_id',$v))->get();
|
||||
|
||||
return response()->json($listPanen);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user