update
This commit is contained in:
parent
21510302a8
commit
fd5146f70f
@ -12,22 +12,22 @@
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\dept;
|
||||
namespace app\adminapi\validate\dept;
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminDept;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminDept;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 部门验证器
|
||||
* Class DeptValidate
|
||||
* @package app\adminapi\validate\dept
|
||||
*/
|
||||
class DeptValidate extends BaseValidate
|
||||
{
|
||||
class DeptValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkDept',
|
||||
@ -62,7 +62,7 @@ class DeptValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true)->append('name','checkUniqueByAdd');
|
||||
return $this->remove('id', true)->append('name', 'checkUniqueByAdd');
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ class DeptValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','org_id','name','leader','mobile','status'])->append('name','checkUniqueByEdit');;
|
||||
return $this->only(['id', 'org_id', 'name', 'leader', 'mobile', 'status'])->append('name', 'checkUniqueByEdit');;
|
||||
}
|
||||
|
||||
|
||||
@ -98,23 +98,23 @@ class DeptValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->append('id','checkDept');
|
||||
return $this->only(['id'])->append('id', 'checkDept');
|
||||
}
|
||||
|
||||
//验证唯一
|
||||
public function checkUniqueByAdd($value,$rule,$data): bool|string
|
||||
public function checkUniqueByAdd($value, $rule, $data): bool|string
|
||||
{
|
||||
$dep = Dept::where('org_id',$data['org_id'])->where('name',$data['name'])->findOrEmpty();
|
||||
if(!$dep->isEmpty()){
|
||||
$dep = Dept::where('org_id', $data['org_id'])->where('name', $data['name'])->findOrEmpty();
|
||||
if (!$dep->isEmpty()) {
|
||||
return '部门已存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkUniqueByEdit($value,$rule,$data): bool|string
|
||||
public function checkUniqueByEdit($value, $rule, $data): bool|string
|
||||
{
|
||||
$dep = Dept::where('org_id',$data['org_id'])->where('name',$data['name'])->where('id','<>',$data['id'])->findOrEmpty();
|
||||
if(!$dep->isEmpty()){
|
||||
$dep = Dept::where('org_id', $data['org_id'])->where('name', $data['name'])->where('id', '<>', $data['id'])->findOrEmpty();
|
||||
if (!$dep->isEmpty()) {
|
||||
return '部门已存在';
|
||||
}
|
||||
return true;
|
||||
@ -140,12 +140,14 @@ class DeptValidate extends BaseValidate
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkLeader($value){
|
||||
$data = Admin::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
public function checkLeader($value)
|
||||
{
|
||||
if (empty($value)) return true;
|
||||
$data = Admin::where('id', $value)->findOrEmpty();
|
||||
if ($data->isEmpty()) {
|
||||
return '负责人信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user