refactor(admin): move auth_ids explode logic to model
- Remove auth_ids explode logic from Admin controller - Add getAuthIdsAttr method to SystemAdmin model for auth_ids parsing - This change improves code organization and reusability
This commit is contained in:
@@ -99,7 +99,6 @@ class Admin extends AdminController
|
||||
}
|
||||
$save ? $this->success('保存成功') : $this->error('保存失败');
|
||||
}
|
||||
$row->auth_ids = explode(',', $row->auth_ids ?: '');
|
||||
$this->assign('row', $row);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@ class SystemAdmin extends TimeModel
|
||||
],
|
||||
];
|
||||
|
||||
public function getAuthIdsAttr($value): array
|
||||
{
|
||||
if (!$value) return [];
|
||||
return explode(',', $value);
|
||||
}
|
||||
|
||||
public function getAuthList(): array
|
||||
{
|
||||
return (new SystemAuth())->removeOption('where')->where('status', 1)->column('title', 'id');
|
||||
|
||||
Reference in New Issue
Block a user