创建模型验证器,验证数据正确性
This commit is contained in:
24
app/common/validate/UserNoticeRead.php
Normal file
24
app/common/validate/UserNoticeRead.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class UserNoticeRead extends Validate
|
||||
{
|
||||
protected $failException = true;
|
||||
|
||||
protected $rule = [
|
||||
'user_id' => 'require|integer|gt:0',
|
||||
'notice_id' => 'require|integer|gt:0',
|
||||
'confirmed' => 'in:0,1',
|
||||
'read_at' => 'integer',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['user_id', 'notice_id', 'confirmed', 'read_at'],
|
||||
'edit' => ['user_id', 'notice_id', 'confirmed', 'read_at'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user