wugg пре 9 месеци
родитељ
комит
e2a267848d
2 измењених фајлова са 5 додато и 4 уклоњено
  1. 2 2
      app/bug/controller/WorkRole.php
  2. 3 2
      app/bug/model/WorkRole.php

+ 2 - 2
app/bug/controller/WorkRole.php

@@ -85,7 +85,7 @@ class WorkRole extends Base{
 					    'status|状态'=>'require|number|in:0,1'
 					    ]);
 		if($valid->check($param)==false) return error($valid->getError());
-		$info = $this->model->findOrEmpty($param['id']);
+		$info = $this->model->with(['companyInfo','workInfo'])->findOrEmpty($param['id']);
 		if($info->isEmpty())return error('岗位角色信息不存在');
 		$info->status=$param['status'];
 		$add = $info->save();
@@ -109,7 +109,7 @@ class WorkRole extends Base{
 		if($param['belong']!='')$where[]=['belong','=',$param['belong']];
 		if($param['role_name']!='')$where[]=['role_name','like',"%{$param['role_name']}%"];
 		if($param['work_id']!='')$where[]=['work_id','=',$param['work_id']];
-		$list =$this->model->with(["companyName","workInfo"])->where($where)->order('id desc')->paginate(['list_rows'=>$param['size'],
+		$list =$this->model->with(['companyInfo','workInfo'])->where($where)->order('id desc')->paginate(['list_rows'=>$param['size'],
 		'page'=>$param['page']]);
 		foreach ($list->items() as &$item){
 			$item["usedNum"] = WorkUser::where(['role_id'=>$item->id])->count();

+ 3 - 2
app/bug/model/WorkRole.php

@@ -1,7 +1,8 @@
 <?php
 namespace app\bug\model;
 
-use app\user\model\Headquarters;use think\model\concern\SoftDelete;
+use app\user\model\Headquarters;
+use think\model\concern\SoftDelete;
 class WorkRole extends Base
 {
 	use SoftDelete;
@@ -24,7 +25,7 @@ class WorkRole extends Base
     protected $createTime='createTime';
     protected $deleteTime = 'delete_time';
     
-    public function CompanyName(){
+    public function companyInfo(){
     	return $this->belongsTo(Headquarters::class,"companyNo","code")->bind(["companyName"=>"name"]);
     }