first commit
This commit is contained in:
69
app/Core/Validator/PropertyRoom/PropertyRoomAddValidator.php
Normal file
69
app/Core/Validator/PropertyRoom/PropertyRoomAddValidator.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyRoom;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use App\Models\PropertyRoom;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyRoomAddValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'name' => 'required',
|
||||
"checkName" => "accepted",
|
||||
'room_type_id' => 'required|numeric',
|
||||
'room_type_count' => 'required|numeric',
|
||||
'max_occupancy' => 'required|numeric',
|
||||
'max_adult' => 'required|numeric',
|
||||
'max_child' => 'required|numeric',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
public function checkName($params)
|
||||
{
|
||||
try {
|
||||
$roomRate = PropertyRoom::where('property_id', $params['property_id'])
|
||||
->where('name', $params['name'])
|
||||
->first();
|
||||
return $roomRate ? false : true;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
$params["checkName"] = $this->checkName(['property_id' => $params["property_id"], 'name' => $params["name"] ]);
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyRoom;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use App\Models\PropertyRoom;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyRoomAndBedAddValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'name' => 'required|max:200',
|
||||
"checkName" => "accepted",
|
||||
'room_type_id' => 'required|numeric',
|
||||
'room_type_count' => 'required|numeric',
|
||||
'max_occupancy' => 'required|numeric|min:1',
|
||||
'max_adult' => 'required|numeric',
|
||||
'max_child' => 'required|numeric',
|
||||
'room_bed_group' => 'nullable|array',
|
||||
'room_bed_group.*' => 'nullable|array',
|
||||
'room_bed_group.*.*.bed_type_id' => 'nullable|numeric',
|
||||
'exclude_occupancy' => 'nullable|max:500',
|
||||
'room_size_type' => 'required|max:30',
|
||||
'room_size' => 'required|max:11',
|
||||
'is_connected_room' => 'nullable|boolean',
|
||||
'is_connected_room_price' => 'nullable|boolean',
|
||||
'is_connected_room_availability' => 'nullable|boolean',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
|
||||
public function checkName($params)
|
||||
{
|
||||
try {
|
||||
$roomRate = PropertyRoom::where('property_id', $params['property_id'])
|
||||
->where('name', $params['name'])
|
||||
->where('room_type_id', $params['room_type_id'])
|
||||
->where('status', 1)
|
||||
->first();
|
||||
return $roomRate ? false : true;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
$params["checkName"] = $this->checkName(['property_id' => $params["property_id"], 'name' => $params["name"], 'room_type_id' => $params['room_type_id'] ]);
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyRoom;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use App\Models\PropertyRoom;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyRoomAndBedUpdateValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'room_id' => 'required|numeric',
|
||||
'name' => 'required|max:200',
|
||||
"checkName" => "accepted",
|
||||
'room_type_id' => 'required|numeric',
|
||||
'room_type_count' => 'required|numeric',
|
||||
'max_occupancy' => 'required|numeric|min:1',
|
||||
'max_adult' => 'required|numeric',
|
||||
'max_child' => 'required|numeric',
|
||||
'room_bed_group' => 'nullable|array',
|
||||
'room_bed_group.*' => 'nullable|array',
|
||||
'room_bed_group.*.*.bed_type_id' => 'nullable|numeric',
|
||||
'exclude_occupancy' => 'nullable|max:500',
|
||||
'room_size_type' => 'required|max:30',
|
||||
'room_size' => 'required|max:11',
|
||||
'is_connected_room' => 'nullable|boolean',
|
||||
'is_connected_room_price' => 'nullable|boolean',
|
||||
'is_connected_room_availability' => 'nullable|boolean',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
|
||||
public function checkName($params)
|
||||
{
|
||||
try {
|
||||
$roomRate = PropertyRoom::where('property_id', $params['property_id'])
|
||||
->where('name', $params['name'])
|
||||
->where('room_type_id', $params['room_type_id'])
|
||||
->where('id', '!=', $params['room_id'])
|
||||
->where('status', 1)
|
||||
->first();
|
||||
|
||||
return $roomRate ? false : true;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
$params["checkName"] = $this->checkName(
|
||||
[
|
||||
'property_id' => $params["property_id"],
|
||||
'name' => $params["name"],
|
||||
'room_id' => $params['room_id'] ,
|
||||
'room_type_id' => $params['room_type_id']
|
||||
]);
|
||||
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyRoom;
|
||||
|
||||
use App\Models\Property;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyRoomDeleteValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'id' => '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,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyRoom;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use App\Models\PropertyRoom;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyRoomFactMappingAddValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'room_id' => 'required|numeric',
|
||||
"checkPropertyRoom" => "accepted",
|
||||
'property_room_fact' => 'required|array',
|
||||
'property_room_fact.*.id' => 'required|numeric',
|
||||
'property_room_fact.*.is_selected' => 'required|boolean',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
public function checkPropertyRoom($params)
|
||||
{
|
||||
try {
|
||||
$roomData = PropertyRoom::where('property_id', $params['property_id'])
|
||||
->where('id', $params['room_id'])
|
||||
->first();
|
||||
|
||||
return $roomData ? true : false;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
$params["checkPropertyRoom"] = $this->checkPropertyRoom(['property_id' => $params["property_id"], 'room_id' => $params["room_id"] ]);
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyRoom;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyRoomInventoryValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'channel_id' => '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,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyRoom;
|
||||
|
||||
use App\Models\PropertyPhoto;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use App\Models\PropertyRoom;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyRoomPhotoMappingAddValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'property_id' => 'required|numeric',
|
||||
'room_id' => 'required|numeric',
|
||||
"checkPropertyRoom" => "accepted",
|
||||
"checkPropertyPhoto" => "accepted",
|
||||
'property_room_photo' => 'required|array',
|
||||
'property_room_photo.*.id' => 'required|numeric',
|
||||
'property_room_photo.*.is_selected' => 'required|boolean',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
public function checkPropertyRoom($params)
|
||||
{
|
||||
try {
|
||||
$roomData = PropertyRoom::where('property_id', $params['property_id'])
|
||||
->where('id', $params['room_id'])
|
||||
->first();
|
||||
|
||||
return $roomData ? true : false;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkPropertyPhoto($params)
|
||||
{
|
||||
try {
|
||||
|
||||
$photos = collect($params['property_room_photo'])->keyBy('id')->keys()->toArray();
|
||||
$arrayCount = collect($params['property_room_photo'])->count();
|
||||
$photoData = PropertyPhoto::where('property_id', $params['property_id'])
|
||||
->whereIn('id', $photos)
|
||||
->count();
|
||||
return $arrayCount == $photoData ? true : false;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
$params["checkPropertyRoom"] = $this->checkPropertyRoom(['property_id' => $params["property_id"], 'room_id' => $params["room_id"] ]);
|
||||
$params["checkPropertyPhoto"] = $this->checkPropertyPhoto(['property_id' => $params["property_id"], 'property_room_photo' => $params["property_room_photo"] ]);
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyRoom;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use App\Models\PropertyRoom;
|
||||
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyRoomUpdateValidator extends BaseValidator
|
||||
{
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
'id' => 'required|numeric',
|
||||
'name' => 'required',
|
||||
"checkName" => "accepted",
|
||||
'room_type_id' => 'required|numeric',
|
||||
'room_type_count' => 'required|numeric',
|
||||
'max_occupancy' => 'required|numeric',
|
||||
'max_adult' => 'required|numeric',
|
||||
'max_child' => 'required|numeric',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
|
||||
public function checkName($params)
|
||||
{
|
||||
try {
|
||||
$roomRate = PropertyRoom::where('property_id', $params['property_id'])
|
||||
->where('name', $params['name'])
|
||||
->where('id', '!=' ,$params['id'])
|
||||
->first();
|
||||
return $roomRate ? false : true;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
|
||||
$params["checkName"] = $this->checkName(['property_id' => $params["property_id"], 'name' => $params["name"], 'id' => $params["id"] ]);
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user