<?php

namespace App\Core\Service;

use App\Core\Repository\PropertyRoomViewType\PropertyRoomViewTypeRepository;


use App;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Config;
use Exception;
use App\Exceptions\ApiErrorException;

class PropertyRoomViewTypeService
{

    private $propertyRoomViewTypeRepository;


    public function __construct(

        PropertyRoomViewTypeRepository $propertyRoomViewTypeRepository
    )
    {

        $this->propertyRoomViewTypeRepository = $propertyRoomViewTypeRepository;

    }

    public function getPropertyRoomViewTypes($params)
    {
        $response = ['status' => -1, 'message' => '', 'data' => null];
        try {

            $propertyRoomViewTypes = $this->propertyRoomViewTypeRepository->findByCriteria($params, ['id', 'name', 'language_key']);

            if (empty($propertyRoomViewTypes)) {
                throw new ApiErrorException(lang('Property Room View Type Not Found.'));
            }

            $response = [
                'status' => true,
                'data' => $propertyRoomViewTypes,
            ];

        } catch (ApiErrorException $e) {
            $response['message'] = $e->getMessage();
        } catch (Exception $e) {
            $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
            Log::error($message);
            $response['message'] = $e->getMessage();
        }

        return output($response);
    }


}
