initial commit
This commit is contained in:
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