webman后台
This commit is contained in:
22
dafuweng-webman/support/bootstrap/ValidateInit.php
Normal file
22
dafuweng-webman/support/bootstrap/ValidateInit.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace support\bootstrap;
|
||||
|
||||
use think\Validate;
|
||||
use support\think\Db;
|
||||
use Workerman\Worker;
|
||||
|
||||
/**
|
||||
* 验证器引导:为 think-validate 注入 Db,使 unique 等规则可用
|
||||
*/
|
||||
class ValidateInit implements \Webman\Bootstrap
|
||||
{
|
||||
public static function start(?Worker $worker): void
|
||||
{
|
||||
Validate::maker(function (Validate $validate): void {
|
||||
$validate->setDb(Db::connect());
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user