138 lines
4.2 KiB
PHP
138 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace App\Core\Service;
|
|
|
|
use App\Core\Repository\Booking\BookingContactRepository;
|
|
|
|
use App;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Exception;
|
|
use App\Exceptions\ApiErrorException;
|
|
|
|
class BookingContactService
|
|
{
|
|
|
|
private $bookingRepository;
|
|
private $bookingRoomRepository;
|
|
private $bookingRoomPaxRepository;
|
|
private $bookingContactRepository;
|
|
private $bookingPaymentRepository;
|
|
|
|
|
|
public function __construct(
|
|
|
|
BookingContactRepository $bookingContactRepository
|
|
|
|
)
|
|
{
|
|
|
|
$this->bookingContactRepository = $bookingContactRepository;
|
|
|
|
}
|
|
|
|
public function create($params = [])
|
|
{
|
|
$response = ['status' => -1, 'message' => '', 'data' => null];
|
|
try {
|
|
|
|
/*$validationResult = $this->propertyChannelAddValidator->validate($params);
|
|
|
|
if ($validationResult->errors()->first()) {
|
|
$errors = $validationResult->errors()->all();
|
|
throw new ApiErrorException($errors);
|
|
}*/
|
|
|
|
$insertData = [
|
|
'booking_id' => fillOnUndefined($params, 'booking_id'),
|
|
'name' => fillOnUndefined($params, 'name'),
|
|
'surname' => fillOnUndefined($params, 'surname'),
|
|
'phone_code' => fillOnUndefined($params, 'phone_code'),
|
|
'phone_number' => fillOnUndefined($params, 'phone_number'),
|
|
'email' => fillOnUndefined($params, 'email'),
|
|
'country_code' => fillOnUndefined($params, 'country_code'),
|
|
'note' => fillOnUndefined($params, 'note'),
|
|
'invoice_request' => fillOnUndefined($params, 'invoice_request'),
|
|
'language_code' => fillOnUndefined($params, 'language_code', 'en'),
|
|
'extra_param' => fillOnUndefined($params, 'extra_param'),
|
|
'status' => fillOnUndefined($params, 'status', 1),
|
|
];
|
|
|
|
$userCreateResult = $this->bookingContactRepository->create($insertData);
|
|
|
|
if ($userCreateResult['status'] != 'success') {
|
|
throw new Exception('api-unknown_error');
|
|
}
|
|
$userData = $userCreateResult["data"];
|
|
$response = [
|
|
'status' => true,
|
|
'data' => $userData,
|
|
];
|
|
|
|
} catch (ApiErrorException $e) {
|
|
$response['message'] = implode(', ', $e->getMessageArr());
|
|
} catch (Exception $e) {
|
|
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
|
Log::error($message);
|
|
$response['message'] = $e->getMessage();
|
|
}
|
|
|
|
return output($response);
|
|
}
|
|
|
|
public function select($param = [], $column = ['*'])
|
|
{
|
|
|
|
$response = ['status' => -1, 'message' => '', 'data' => null];
|
|
|
|
try {
|
|
|
|
$data = $this->bookingContactRepository->findByCriteria($param, $column);
|
|
|
|
$response = [
|
|
'status' => true,
|
|
'data' => $data,
|
|
];
|
|
|
|
} 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);
|
|
}
|
|
|
|
public function update($id, $param = [])
|
|
{
|
|
|
|
|
|
$response = ['status' => -1, 'message' => '', 'data' => null];
|
|
try {
|
|
|
|
|
|
$updateResult = $this->bookingContactRepository->update($id, $param);
|
|
if ($updateResult['status'] != 'success') {
|
|
throw new Exception('api-unknown_error');
|
|
}
|
|
$updateData = $updateResult["data"];
|
|
$response = [
|
|
'status' => true,
|
|
'data' => $updateData,
|
|
];
|
|
|
|
} catch (ApiErrorException $e) {
|
|
$response['message'] = implode(', ', $e->getMessageArr());
|
|
} catch (Exception $e) {
|
|
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
|
Log::error($message);
|
|
$response['message'] = $e->getMessage();
|
|
}
|
|
|
|
return output($response);
|
|
}
|
|
|
|
}
|