first commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Validator\PropertyContact;
|
||||
|
||||
|
||||
use GPBMetadata\Google\Api\Log;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use App\Core\Repository\PropertyContact\PropertyContactRepository;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyContactCreateValidator extends BaseValidator
|
||||
{
|
||||
private $propertyContactRepository;
|
||||
|
||||
public function __construct
|
||||
(
|
||||
PropertyContactRepository $propertyContactRepository,
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
$this->propertyContactRepository = $propertyContactRepository;
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
// 'property_id' => 'required|integer|unique:property_contact,property_id', // todo: It should be added uniqueness
|
||||
"checkMainPhoneAndMobilePhone" => "accepted",
|
||||
'phone' => 'nullable|max:50',
|
||||
'mobile' => 'nullable|max:50',
|
||||
'mobile2' => 'nullable|max:50',
|
||||
'fax' => 'nullable|max:50',
|
||||
'email' => 'required|email|max:100',
|
||||
'web' => 'nullable|max:100',
|
||||
'zip_code' => 'nullable|max:20',
|
||||
'address' => 'nullable|max:200',
|
||||
'latitude' => 'nullable',
|
||||
'longitude' => 'nullable',
|
||||
'status' => 'required|integer|max:4',
|
||||
'created_by' => 'required|integer',
|
||||
'updated_by' => 'required|integer',
|
||||
'social_media_addresses' => 'nullable|json|max:512',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [
|
||||
'checkMainPhoneAndMobilePhone.accepted' => 'phone or mobile phone required' // TODO : language key eklenicek
|
||||
];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
|
||||
public function checkMainPhoneAndMobilePhone($params)
|
||||
{
|
||||
if (empty($params['phone']) && empty($params['mobile'])) {
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
$params["checkMainPhoneAndMobilePhone"] = $this->checkMainPhoneAndMobilePhone( $params);
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Core\Validator\PropertyContact;
|
||||
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use App\Core\Repository\PropertyContact\PropertyContactRepository;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use App\Core\Validator\BaseValidator;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PropertyContactUpdateValidator extends BaseValidator
|
||||
{
|
||||
private $propertyContactRepository;
|
||||
|
||||
public function __construct
|
||||
(
|
||||
PropertyContactRepository $propertyContactRepository,
|
||||
Translator $translator,
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($translator, $container);
|
||||
$this->propertyContactRepository = $propertyContactRepository;
|
||||
}
|
||||
|
||||
public function rules($params = null)
|
||||
{
|
||||
return
|
||||
[
|
||||
"checkMainPhoneAndMobilePhone" => "accepted",
|
||||
'email' => 'required|email|max:100',
|
||||
'phone' => 'nullable|max:50',
|
||||
'mobile' => 'nullable|max:50',
|
||||
'mobile2' => 'nullable|max:50',
|
||||
'fax' => 'nullable|max:50',
|
||||
'web' => 'nullable|max:100',
|
||||
'zip_code' => 'nullable|max:20',
|
||||
'address' => 'nullable|max:200',
|
||||
'latitude' => 'nullable',
|
||||
'longitude' => 'nullable',
|
||||
'social_media_addresses' => 'nullable|json|max:512',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$thisMessages = [
|
||||
'checkMainPhoneAndMobilePhone.accepted' => 'phone or mobile phone required' // TODO : language key eklenicek
|
||||
];
|
||||
return array_merge(parent::messages() , $thisMessages);
|
||||
}
|
||||
|
||||
public function checkMainPhoneAndMobilePhone($params)
|
||||
{
|
||||
if (empty($params['phone']) && empty($params['mobile'])) {
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
$params["checkMainPhoneAndMobilePhone"] = $this->checkMainPhoneAndMobilePhone($params);
|
||||
return $this->make($params, $this->rules($params), $this->messages());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user