initial commit
This commit is contained in:
56
app/Rules/PasswordValidationRule.php
Normal file
56
app/Rules/PasswordValidationRule.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class PasswordValidationRule implements Rule
|
||||
{
|
||||
protected string $password_validation_rule = '/^(?=[-a-zA-Z0-9!@_*.]*$).*/';
|
||||
protected string $identity_iq_password_validation_rule = '/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/'; // identity iq
|
||||
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$inputData = request()->all();
|
||||
$source_type = '';
|
||||
if(!empty($inputData['creditreport'])){
|
||||
$source_type = $inputData['creditreport']['credit_report_company_type'];
|
||||
}if(!empty($inputData['source_type'])){
|
||||
$source_type = $inputData['source_type'];
|
||||
}
|
||||
if($source_type == config('constant.reportType.SMART_CREDIT'))
|
||||
{
|
||||
return preg_match($this->password_validation_rule,$value);
|
||||
}
|
||||
elseif ($source_type == config('constant.reportType.IDENTITY_IQ')){
|
||||
return preg_match($this->identity_iq_password_validation_rule,$value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return 'Password must be 8 characters and include a capital, lowercase, number and symbol.';
|
||||
}
|
||||
}
|
||||
54
app/Rules/ReCaptcha.php
Normal file
54
app/Rules/ReCaptcha.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use App\Utility\Curl;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class ReCaptcha implements Rule
|
||||
{
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
// google captcha url
|
||||
$url = "https://www.google.com/recaptcha/api/siteverify";
|
||||
|
||||
// captcha secret key and value from the UI
|
||||
$data = [
|
||||
'secret' => config('app.GOOGLE_RECAPTCHA_SECRET'),
|
||||
'response' => $value
|
||||
];
|
||||
|
||||
|
||||
|
||||
$response = (new Curl($url))->get($data);
|
||||
|
||||
return $response['success'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return 'The validation error message.';
|
||||
}
|
||||
}
|
||||
50
app/Rules/TraningVideoValidationRule.php
Normal file
50
app/Rules/TraningVideoValidationRule.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use App\Models\VideoSetting;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class TraningVideoValidationRule implements Rule
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$inputData = request()->all();
|
||||
|
||||
if(isset($inputData['welcome_video_create']) && $inputData['welcome_video_create']) {
|
||||
$inputData['is_welcome_video'] = true;
|
||||
$videos=(new VideoSetting())->getVideos($inputData);
|
||||
if($videos->isEmpty()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return 'Already set welcome video.';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user