first commit
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyChannelMapping;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyChannelMappingAddValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'channels' => 'required|array',
|
||||
'channels.*' => 'required|numeric'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyChannelMapping;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyChannelMappingRemoveValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'channels' => 'required|array',
|
||||
'channels.*' => 'numeric'
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyChannelMapping;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyChannelMappingUpdateValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'property_channel' => 'required|array',
|
||||
'property_channel.*.id' => 'required|numeric',
|
||||
'property_channel.*.is_selected' => 'required|boolean',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyChannelMapping;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyChannelSetupValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
$rules =
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'channel_id' => 'required|numeric',
|
||||
'checkPayment' => 'accepted',
|
||||
'booking' => 'array',
|
||||
'payment' => 'array',
|
||||
'availability' => 'array',
|
||||
'availability.availability_type_id' => 'numeric',
|
||||
|
||||
] ;
|
||||
|
||||
|
||||
if(isset($params['booking']['value'])){
|
||||
$optionalRules = [
|
||||
'booking.booking_type_id' => 'required|numeric',
|
||||
'booking.action_type' => 'required|in:INC,DEC',
|
||||
'booking.value_type' => 'required|in:FIX,PER',
|
||||
'booking.value' => 'numeric',
|
||||
] ;
|
||||
$rules = array_merge($rules, $optionalRules) ;
|
||||
}
|
||||
|
||||
return $rules ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
|
||||
public function paymentValueControl($params){
|
||||
try {
|
||||
$errorStatus = false ;
|
||||
|
||||
foreach ($params['payment'] as $payment) {
|
||||
if(
|
||||
($payment['value']) &&
|
||||
(
|
||||
$payment['action_type'] == null || $payment['value_type'] == null ||
|
||||
!in_array($payment['action_type'], ['INC', 'DEC']) || !in_array($payment['value_type'], ['FIX', 'PER'])
|
||||
|
||||
)
|
||||
){
|
||||
$errorStatus = true ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $errorStatus ? false : true;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
$params["checkPayment"] = $this->paymentValueControl($params);
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user