55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
use App\Promotions;
|
|
|
|
class PhotoSliderDateEnd implements Rule
|
|
{
|
|
protected $request;
|
|
|
|
/**
|
|
* Create a new rule instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($request)
|
|
{
|
|
$this->request = $request;
|
|
}
|
|
|
|
/**
|
|
* Determine if the validation rule passes.
|
|
*
|
|
* @param string $attribute
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public function passes($attribute, $value)
|
|
{
|
|
if(isset($this->request->promotion_uuid) && $this->request->promotion_uuid != '')
|
|
{
|
|
$promotion = Promotions::where('promotion_uuid',$this->request->promotion_uuid)->first();
|
|
|
|
if($promotion)
|
|
{
|
|
if(strtotime($promotion->date_end) < strtotime($value))
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation error message.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function message()
|
|
{
|
|
return 'Invalid Date End';
|
|
}
|
|
}
|