新增部门和岗位

This commit is contained in:
yanwenwu
2020-01-12 09:30:56 +08:00
parent 5ec9939cbf
commit 8b93c63883
11 changed files with 100 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ use catcher\base\CatchModel;
class Department extends CatchModel
{
protected $name = 'department';
protected $name = 'departments';
protected $field = [
'id', //
@@ -31,7 +31,12 @@ class Department extends CatchModel
*/
public function getList($params)
{
return $this->when($params['department_name'] ?? false, function ($query) use ($params){
return $this->field([
'id',
'department_name as title', 'parent_id', 'principal', 'mobile', 'email', 'creator_id', 'status', 'sort',
'created_at', 'updated_at'
])
->when($params['department_name'] ?? false, function ($query) use ($params){
$query->whereLike('department_name', '%' . $params['department_name'] . '%');
})
->when($params['status'] ?? false, function ($query) use ($params){

View File

@@ -0,0 +1,58 @@
<?php
namespace catchAdmin\permissions\model;
trait HasJobsTrait
{
/**
*
* @time 2019年12月08日
* @return mixed
*/
public function jobs()
{
return $this->belongsToMany(Job::class, 'user_has_jobs', 'job_id', 'uid');
}
/**
*
* @time 2019年12月08日
* @param array $fields
* @return mixed
*/
public function getJobs()
{
return $this->jobs()->select();
}
/**
*
* @time 2019年12月08日
* @param array $jobs
* @return mixed
*/
public function attachJobs(array $jobs)
{
if (empty($jobs)) {
return true;
}
sort($jobs);
return $this->jobs()->attach($jobs);
}
/**
*
* @time 2019年12月08日
* @param array $jobs
* @return mixed
*/
public function detachJobs(array $jobs = [])
{
if (empty($jobs)) {
return $this->jobs()->detach();
}
return $this->jobs()->detach($jobs);
}
}

View File

@@ -5,7 +5,7 @@ use catcher\base\CatchModel;
class Job extends CatchModel
{
protected $name = 'job';
protected $name = 'jobs';
protected $field = [
'id', //