修正行政区域添加后无法选择

This commit is contained in:
乐风 2021-06-19 16:06:01 +08:00
parent 50ee24192f
commit fb85089b38
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,40 @@
<?php namespace Gdoo\System\Hooks;
use DB;
use Gdoo\System\Models\Region;
class RegionHook
{
static $linkOptions = [];
public function onBeforeForm($params) {
return $params;
}
public function onAfterForm($params) {
return $params;
}
public function onBeforeStore($params) {
$master = $params['master'];
$master['parent_id'] = (int)$master['parent_id'];
$master['layer'] = 1;
if ($master['parent_id'] > 0) {
$parent = Db::table('region')->where('id', $master['parent_id'])->first();
$master['layer'] = $parent['layer'] + 1;
}
$params['master'] = $master;
return $params;
}
public function onAfterStore($params) {
return $params;
}
public function onBeforeDelete($params) {
return $params;
}
}

View File

@ -10,6 +10,9 @@ return [
'url' => 'system/region/dialog',
],
],
"listens" => [
'region' => 'Gdoo\System\Hooks\RegionHook',
],
"controllers" => [
"setting" => [
"name" => "基础设置",