PHP Classes

File: apps/ApiGateway/app/Http/Controllers/AvailableHotelsController.php

Recommend this page to a friend!
  Classes of mohammad anzawi   PHP Hotel Booking Available   apps/ApiGateway/app/Http/Controllers/AvailableHotelsController.php   Download  
File: apps/ApiGateway/app/Http/Controllers/AvailableHotelsController.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Hotel Booking Available
Search for hotels that are available for booking
Author: By
Last change:
Date: 2 years ago
Size: 1,454 bytes
 

Contents

Class file image Download
<?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,
        ]));
    }
}