154 lines
4.6 KiB
PHP
154 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Access;
|
|
|
|
use App\Constant\Constant;
|
|
use App\Http\Requests\Api\Chaturmas\GetChaturmasRequest;
|
|
use App\Http\Requests\Api\Chaturmas\StoreChaturmasRequest;
|
|
use App\Http\Requests\Api\Chaturmas\UpdateChaturmasRequest;
|
|
use App\Repositories\Api\Access\Chaturmas\ChaturmasInterface as ChaturmasRepository;
|
|
use App\Models\Chaturmas;
|
|
use Exception;
|
|
use App\Http\Controllers\Api\ApiController;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ChaturmasController extends ApiController
|
|
{
|
|
/**
|
|
* @param ChaturmasRepository $chaturmasRepository
|
|
* ChaturmasController constructor.
|
|
*/
|
|
public function __construct(ChaturmasRepository $chaturmasRepository)
|
|
{
|
|
$this->chaturmasRepository = $chaturmasRepository;
|
|
}
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index(GetChaturmasRequest $request)
|
|
{
|
|
try {
|
|
$response = $this->chaturmasRepository->getChaturmasList($request->all());
|
|
$this->updateStatusCode($response);
|
|
|
|
return $this->respond($response);
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->respondInternalError(trans('api.something_went_wrong'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param App\Http\Requests\Api\Chaturmas\StoreChaturmasRequest $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(StoreChaturmasRequest $request)
|
|
{
|
|
try {
|
|
$response = $this->chaturmasRepository->storeChaturmas($request->all());
|
|
$this->updateStatusCode($response);
|
|
$this->setStatusCode($response['status']);
|
|
} catch (Exception $ex) {
|
|
$response['message'] = $ex->getMessage();
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
|
|
return $this->respond($response);
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\Models\Chaturmas $chaturma
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show(Chaturmas $chaturma)
|
|
{
|
|
try {
|
|
$response = $this->chaturmasRepository->showChaturmas($chaturma);
|
|
$this->updateStatusCode($response);
|
|
$this->setStatusCode($response['status']);
|
|
} catch (Exception $ex) {
|
|
$response['error'] = $ex->getMessage();
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
|
|
return $this->respond($response);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param App\Http\Requests\Api\Chaturmas\UpdateChaturmasRequest $request
|
|
* @param \App\Models\Chaturmas $chaturma
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(UpdateChaturmasRequest $request, Chaturmas $chaturma)
|
|
{
|
|
try {
|
|
$response = $this->chaturmasRepository->updateChaturmas($request->all(), $chaturma);
|
|
$this->updateStatusCode($response);
|
|
$this->setStatusCode($response['status']);
|
|
} catch (\Exception $ex) {
|
|
$response['error'] = $ex->getMessage();
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
return $this->respond($response);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Models\Chaturmas $chaturma
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Chaturmas $chaturma)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\Models\Chaturmas $chaturma
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function getChaturmasYears()
|
|
{
|
|
try {
|
|
$response = $this->chaturmasRepository->getChaturmasYears();
|
|
$this->updateStatusCode($response);
|
|
$this->setStatusCode($response['status']);
|
|
} catch (Exception $ex) {
|
|
$response['error'] = $ex->getMessage();
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
|
|
return $this->respond($response);
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\Models\Chaturmas $chaturma
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function getHundredChaturmasYears()
|
|
{
|
|
try {
|
|
$response = $this->chaturmasRepository->getHundredChaturmasYears();
|
|
$this->updateStatusCode($response);
|
|
$this->setStatusCode($response['status']);
|
|
} catch (Exception $ex) {
|
|
$response['error'] = $ex->getMessage();
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
|
|
return $this->respond($response);
|
|
}
|
|
}
|