<?php
namespace App\Http\Controllers;
use App\Services\AvailableHotelsService;
use App\Traits\ApiResponser;
use Illuminate\Http\Request;
class AvailableHotelsController extends Controller
{
use ApiResponser;
/**
* @var AvailableHotelsService
*/
private $_availableHotelsService;
/**
* Create a new controller instance.
* using injection dependency for AvailableHotelsService
* @return void
*/
public function __construct(AvailableHotelsService $service)
{
$this->_availableHotelsService = $service;
$this->_defaultProvider = env('DEFAULT_HOTELS_PROVIDER', 'BestHotels');
}
/**
* get all available hotels from -AvailableHotelsService-
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|\Laravel\Lumen\Http\ResponseFactory
*/
public function index(Request $request)
{
$provider = $request->has('provider') ? $request->provider : null;
return $this->successResponse($this->_availableHotelsService->obtainAvailableHotels([
'provider' => $provider,
]));
}
public function search(Request $request)
{
$provider = $request->has('provider') ? $request->provider : null;
return $this->successResponse($this->_availableHotelsService->searchInAvailableHotels([
'provider' => $provider,
]));
}
}
|