api code global jain
This commit is contained in:
305
app/Http/Controllers/Api/V1/Access/SantController.php
Normal file
305
app/Http/Controllers/Api/V1/Access/SantController.php
Normal file
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Access;
|
||||
|
||||
use App\Models\Sant;
|
||||
use App\Models\SantTemp;
|
||||
use App\Constant\Constant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Http\Controllers\Api\ApiController;
|
||||
use App\Http\Requests\Api\Sant\StoreSantRequest;
|
||||
use App\Http\Requests\Api\Sant\SantFollowRequest;
|
||||
use App\Http\Requests\Api\Sant\UpdateSantRequest;
|
||||
use App\Repositories\Api\Access\Sant\SantInterface as SantRepository;
|
||||
|
||||
class SantController extends ApiController
|
||||
{
|
||||
|
||||
public function __construct(SantRepository $santRepository)
|
||||
{
|
||||
$this->santRepository = $santRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->getSantList($request->all());
|
||||
$this->setStatusCode($response['status']);
|
||||
} catch (\Exception $ex) {
|
||||
$response['message'] = $ex->getMessage();
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
|
||||
return $this->respond($response);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(StoreSantRequest $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->createSant($request);
|
||||
$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\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Sant $sant)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->showSant($sant);
|
||||
$this->updateStatusCode($response);
|
||||
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->respondInternalError(trans('api.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function showInReviewSant(Sant $sant)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->inReviewSantDetail($sant);
|
||||
$this->updateStatusCode($response);
|
||||
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->respondInternalError(trans('api.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param UpdateSantRequest $request
|
||||
* @param \App\Models\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(UpdateSantRequest $request, Sant $sant)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->updateSant($sant,$request);
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$response['message'] = $ex->getMessage();
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Sant $sant)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get list of father.
|
||||
*
|
||||
* @param \App\Models\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function santFatherList(Request $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->santFatherList($request->all());
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$response['message'] = $ex->getMessage();
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of father.
|
||||
*
|
||||
* @param \App\Models\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function santMotherList(Request $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->santMotherList($request->all());
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$response['message'] = $ex->getMessage();
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of in review sant.
|
||||
*
|
||||
* @param \App\Models\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function inReviewSant(Request $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->inReviewSant($request->all());
|
||||
$this->updateStatusCode($response);
|
||||
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return $this->respondInternalError(trans('api.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of in review sant.
|
||||
*
|
||||
* @param \App\Models\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function userSantList(Request $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->userSantList($request->all());
|
||||
$this->updateStatusCode($response);
|
||||
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return $this->respondInternalError(trans('api.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow sant.
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function santFollow(SantFollowRequest $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->santFollow($request->all());
|
||||
$this->updateStatusCode($response);
|
||||
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return $this->respondInternalError(trans('api.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get suuggestion sant.
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function santSuggestion(Request $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->santSuggestion($request->all());
|
||||
$this->updateStatusCode($response);
|
||||
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return $this->respondInternalError(trans('api.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get suuggestion sant.
|
||||
* @param \App\Models\Sant $sant
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function santFollowers(Request $request,Sant $sant)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->santFollowers($request->all(), $sant);
|
||||
$this->updateStatusCode($response);
|
||||
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return $this->respondInternalError(trans('api.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getSantFeeds(Request $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->getSantFeeds($request->all());
|
||||
$this->setStatusCode($response['status']);
|
||||
} catch (\Exception $ex) {
|
||||
$response['message'] = $ex->getMessage();
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store/updates sant's current location.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function updateSantLocation(Request $request)
|
||||
{
|
||||
try {
|
||||
$response = $this->santRepository->updateSantLocation($request->all());
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$response['message'] = $ex->getMessage();
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
|
||||
return $this->respond($response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user