| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/apache/htdocs/app/app/Http/Controllers/ |
Upload File : |
<?php
namespace App\Http\Controllers;
use App\Http\Services\StateService;
use App\Http\Requests\States\StateListRequest;
use App\Http\Requests\States\GetStateFromPostcodeRequest;
use App\Http\Requests\States\CityListRequest;
class StateController extends Controller
{
public function __construct(
StateService $stateService
)
{
$this->stateService = $stateService;
}
/**
* @OA\Get(
*
* path="/api/state/list",
* operationId="stateList",
* tags={"State"},
* summary="Show list of states",
* security={
* {
* "open_key": {}
* },
* {
* "api_key": {}
* }
* },
* @OA\Response(
* response=200,
* description="Success",
* @OA\JsonContent()
* ),
* @OA\Response(response=400, description="Bad request"),
* @OA\Response(response=404, description="Resource Not Found"),
* @OA\Response(response=422, description="Unprocessable Entity"),
* @OA\Response(response=500, description="Internal Server Error"),
* )
*/
public function stateList(StateListRequest $request)
{
$payload = $request->validated();
$result = $this->stateService->index($payload);
return self::successResponse("Success", $result);
}
/**
* @OA\Get(
*
* path="/api/state/get",
* operationId="getStateFromPostcode",
* tags={"State"},
* summary="Show state info from postcode",
* security={
* {
* "open_key": {}
* },
* {
* "api_key": {}
* }
* },
* @OA\Parameter(
* name="postcode",
* description="Postcode",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Response(
* response=200,
* description="Success",
* @OA\JsonContent()
* ),
* @OA\Response(response=400, description="Bad request"),
* @OA\Response(response=404, description="Resource Not Found"),
* @OA\Response(response=422, description="Unprocessable Entity"),
* @OA\Response(response=500, description="Internal Server Error"),
* )
*/
public function getStateFromPostcode(GetStateFromPostcodeRequest $request)
{
$payload = $request->validated();
$result = $this->stateService->getStateFromPostcode($payload);
return self::successResponse("Success", $result);
}
/**
* @OA\Get(
*
* path="/api/state/city-list",
* operationId="cityList",
* tags={"State"},
* summary="Show list of cities",
* security={
* {
* "open_key": {}
* },
* {
* "api_key": {}
* }
* },
* @OA\Parameter(
* name="state_id",
* description="State ID",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Parameter(
* name="state_name",
* description="State Name",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Response(
* response=200,
* description="Success",
* @OA\JsonContent()
* ),
* @OA\Response(response=400, description="Bad request"),
* @OA\Response(response=404, description="Resource Not Found"),
* @OA\Response(response=422, description="Unprocessable Entity"),
* @OA\Response(response=500, description="Internal Server Error"),
* )
*/
public function getCities(CityListRequest $request)
{
$payload = $request->validated();
$result = $this->stateService->getCities($payload);
return self::successResponse("Success", $result);
}
}