inspeksi tanaman
This commit is contained in:
@@ -35,11 +35,16 @@ class InspeksiTanamanController extends Controller{
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
public function show(string $id)
|
||||
public function show(Request $request, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('petani');
|
||||
|
||||
$lahan_id = $request->filled('lahan_id') ? $request->lahan_id :null;
|
||||
$tanaman_id = $request->filled('tanaman_id') ? $request->tanaman_id : null;
|
||||
|
||||
$lahan = Inspeksi::findOrFail($id);
|
||||
$lahan = Inspeksi::when($lahan_id, fn($q,$v) => $q->where('lahan_id',$v))
|
||||
->when($tanaman_id, fn($q,$v) => $q->where('tanaman_id',$v))
|
||||
->where('petani_id',$id);
|
||||
|
||||
return response()->json($lahan);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user