Files
water_new/modules/Mall/Rules/CityRule.php
2023-03-08 09:16:04 +08:00

39 lines
717 B
PHP

<?php
namespace Modules\Mall\Rules;
use Illuminate\Contracts\Validation\Rule;
use Modules\Mall\Models\Region;
class CityRule implements Rule
{
/**
* Notes: 判断是否通过验证规则
* @Author: <C.Jason>
* @Date : 2020/11/6 9:56 上午
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value): bool
{
$city = Region::find($value);
if ($city->depth != 2) {
return false;
}
return true;
}
/**
* 获取校验错误信息
* @return string
*/
public function message(): string
{
return '市区信息选择有误';
}
}