respondPolicy('school'); } public function picture(PolicyShowRequest $request): JsonResponse { return $this->respondPolicy('picture'); } private function respondPolicy(string $type): JsonResponse { try { $policy = $this->service->getPolicy($type); } catch (\InvalidArgumentException $e) { return $this->error('Policy not found.', Response::HTTP_NOT_FOUND); } catch (\Throwable $e) { return $this->error('Unable to load policy.', Response::HTTP_INTERNAL_SERVER_ERROR); } return $this->success([ 'policy' => new PolicyResource($policy), ]); } }