recover
This commit is contained in:
43
catch/permissions/model/Department.php
Normal file
43
catch/permissions/model/Department.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\DepartmentSearch;
|
||||
use catcher\base\CatchModel;
|
||||
|
||||
class Department extends CatchModel
|
||||
{
|
||||
use DepartmentSearch;
|
||||
|
||||
protected $name = 'departments';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'department_name', // 部门名称
|
||||
'parent_id', // 父级ID
|
||||
'principal', // 负责人
|
||||
'mobile', // 联系电话
|
||||
'email', // 联系又想
|
||||
'creator_id', // 创建人ID
|
||||
'status', // 1 正常 2 停用
|
||||
'sort', // 排序字段
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,null 未删除 timestamp 已删除
|
||||
];
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function getList(): array
|
||||
{
|
||||
return $this->withoutField(['department_name'])
|
||||
->addFields(['department_name as title'])
|
||||
->catchSearch()
|
||||
->select()->toArray();
|
||||
}
|
||||
}
|
57
catch/permissions/model/HasDepartmentsTrait.php
Normal file
57
catch/permissions/model/HasDepartmentsTrait.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
trait HasDepartmentsTrait
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return mixed
|
||||
*/
|
||||
public function departments()
|
||||
{
|
||||
return $this->belongsToMany(Department::class, 'role_has_departments', 'department_id', 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDepartments()
|
||||
{
|
||||
return $this->departments()->select();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $departments
|
||||
* @return mixed
|
||||
*/
|
||||
public function attachDepartments(array $departments)
|
||||
{
|
||||
if (empty($departments)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sort($departments);
|
||||
|
||||
return $this->departments()->attach($departments);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $departments
|
||||
* @return mixed
|
||||
*/
|
||||
public function detachDepartments(array $departments = [])
|
||||
{
|
||||
if (empty($departments)) {
|
||||
return $this->departments()->detach();
|
||||
}
|
||||
|
||||
return $this->departments()->detach($departments);
|
||||
}
|
||||
}
|
58
catch/permissions/model/HasJobsTrait.php
Normal file
58
catch/permissions/model/HasJobsTrait.php
Normal 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);
|
||||
}
|
||||
}
|
76
catch/permissions/model/HasPermissionsTrait.php
Normal file
76
catch/permissions/model/HasPermissionsTrait.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename HasPermissionsTrait.php
|
||||
* @createdAt 2020/1/14
|
||||
* @project https://github.com/yanwenwu/catch-admin
|
||||
* @document http://doc.catchadmin.com
|
||||
* @author JaguarJack <njphper@gmail.com>
|
||||
* @copyright By CatchAdmin
|
||||
* @license https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt
|
||||
*/
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
trait HasPermissionsTrait
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月09日
|
||||
* @return \think\model\relation\BelongsToMany
|
||||
*/
|
||||
public function permissions(): \think\model\relation\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Permissions::class, 'role_has_permissions', 'permission_id', 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $condition
|
||||
* @param array $field
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPermissions($condition = [], $field = [])
|
||||
{
|
||||
return $this->permissions()
|
||||
->when(!empty($field), function ($query) use ($field){
|
||||
$query->field($field);
|
||||
})
|
||||
->when(!empty($condition), function ($query) use ($condition){
|
||||
$query->where($condition);
|
||||
})
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $permissions
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function attach(array $permissions)
|
||||
{
|
||||
if (empty($permissions)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sort($permissions);
|
||||
|
||||
return $this->permissions()->attach($permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $roles
|
||||
* @return mixed
|
||||
*/
|
||||
public function detach(array $roles = [])
|
||||
{
|
||||
if (empty($roles)) {
|
||||
return $this->permissions()->detach();
|
||||
}
|
||||
|
||||
return $this->permissions()->detach($roles);
|
||||
}
|
||||
}
|
58
catch/permissions/model/HasRolesTrait.php
Normal file
58
catch/permissions/model/HasRolesTrait.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
trait HasRolesTrait
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return mixed
|
||||
*/
|
||||
public function roles()
|
||||
{
|
||||
return $this->belongsToMany(Roles::class, 'user_has_roles', 'role_id', 'uid');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $fields
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRoles()
|
||||
{
|
||||
return $this->roles()->select();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $roles
|
||||
* @return mixed
|
||||
*/
|
||||
public function attach(array $roles)
|
||||
{
|
||||
if (empty($roles)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sort($roles);
|
||||
|
||||
return $this->roles()->attach($roles);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @param array $roles
|
||||
* @return mixed
|
||||
*/
|
||||
public function detach(array $roles = [])
|
||||
{
|
||||
if (empty($roles)) {
|
||||
return $this->roles()->detach();
|
||||
}
|
||||
|
||||
return $this->roles()->detach($roles);
|
||||
}
|
||||
}
|
36
catch/permissions/model/Job.php
Normal file
36
catch/permissions/model/Job.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catcher\base\CatchModel;
|
||||
|
||||
class Job extends CatchModel
|
||||
{
|
||||
protected $name = 'jobs';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'job_name', // 岗位名称
|
||||
'coding', // 编码
|
||||
'creator_id', // 创建人ID
|
||||
'status', // 1 正常 2 停用
|
||||
'sort', // 排序字段
|
||||
'description', // 描述
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,null 未删除 timestamp 已删除
|
||||
];
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @time 2020年01月09日
|
||||
* @param $params
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->paginate();
|
||||
}
|
||||
}
|
103
catch/permissions/model/Permissions.php
Normal file
103
catch/permissions/model/Permissions.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\PermissionsSearch;
|
||||
use catcher\base\CatchModel;
|
||||
use think\Model;
|
||||
|
||||
class Permissions extends CatchModel
|
||||
{
|
||||
use PermissionsSearch;
|
||||
|
||||
protected $name = 'permissions';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'permission_name', // 菜单名称
|
||||
'parent_id', // 父级ID
|
||||
'icon',
|
||||
'component', // 组件
|
||||
'redirect',
|
||||
'keepalive',
|
||||
'hide_children_in_menu',
|
||||
'creator_id',
|
||||
'module', // 模块
|
||||
'route', // 路由
|
||||
'method', // 请求方法
|
||||
'permission_mark', // 权限标识
|
||||
'type', // 1 菜单 2 按钮
|
||||
'sort', // 排序字段
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,null 未删除 timestamp 已删除
|
||||
];
|
||||
|
||||
public const MENU_TYPE = 1;
|
||||
public const BTN_TYPE = 2;
|
||||
|
||||
public const GET = 'get';
|
||||
public const POST = 'post';
|
||||
public const PUT = 'put';
|
||||
public const DELETE = 'delete';
|
||||
|
||||
public function getList($isMenu = false)
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->order('sort', 'desc')
|
||||
->order('id', 'desc')
|
||||
->when($isMenu, function ($query){
|
||||
$query->where('type', self::MENU_TYPE);
|
||||
})
|
||||
->select();
|
||||
}
|
||||
|
||||
public function roles(): \think\model\relation\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Roles::class, 'role_has_permissions', 'role_id', 'permission_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户权限
|
||||
*
|
||||
* @time 2020年01月14日
|
||||
* @param array $permissionIds
|
||||
* @return \think\Collection
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
*/
|
||||
public static function getCurrentUserPermissions(array $permissionIds): \think\Collection
|
||||
{
|
||||
return parent::whereIn('id', $permissionIds)
|
||||
->field(['permission_name as title', 'id', 'parent_id',
|
||||
'route', 'icon', 'component', 'redirect',
|
||||
'keepalive as keepAlive', 'hide_children_in_menu', 'type'
|
||||
])
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入后回调 更新 level
|
||||
*
|
||||
* @time 2020年04月22日
|
||||
* @param Model $model
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array|bool|Model|void|null
|
||||
*/
|
||||
public static function onAfterInsert(Model $model)
|
||||
{
|
||||
$model = self::where('id', $model->id)->find();
|
||||
|
||||
if ($model && $model->parent_id) {
|
||||
$parent = self::where('id', $model->parent_id)->find();
|
||||
$level = $parent->level ? $parent->level . '-' . $parent->id : $parent->id;
|
||||
return $model->where('id', $model->id)->update([
|
||||
'level' => $level
|
||||
]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
90
catch/permissions/model/Roles.php
Normal file
90
catch/permissions/model/Roles.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\RolesSearch;
|
||||
use catcher\base\CatchModel;
|
||||
|
||||
class Roles extends CatchModel
|
||||
{
|
||||
use HasDepartmentsTrait;
|
||||
use HasPermissionsTrait;
|
||||
use RolesSearch;
|
||||
|
||||
protected $name = 'roles';
|
||||
|
||||
public const ALL_DATA = 1; // 全部数据
|
||||
public const SELF_CHOOSE = 2; // 自定义数据
|
||||
public const SELF_DATA = 3; // 本人数据
|
||||
public const DEPARTMENT_DATA = 4; // 部门数据
|
||||
public const DEPARTMENT_DOWN_DATA = 5; // 部门及以下数据
|
||||
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'role_name', // 角色名
|
||||
'parent_id', // 父级ID
|
||||
'creator_id', // 创建者
|
||||
'data_range', // 数据范围
|
||||
'description', // 角色备注
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,0未删除 >0 已删除
|
||||
|
||||
];
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @return \think\model\relation\BelongsToMany
|
||||
*/
|
||||
public function users(): \think\model\relation\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Users::class, 'user_has_roles', 'uid', 'role_id');
|
||||
}
|
||||
|
||||
|
||||
public static function getDepartmentUserIdsBy($roles)
|
||||
{
|
||||
$uids = [];
|
||||
|
||||
$isAll = false;
|
||||
|
||||
$user = request()->user();
|
||||
|
||||
foreach ($roles as $role) {
|
||||
switch ($role->data_range) {
|
||||
case self::ALL_DATA:
|
||||
$isAll = true;
|
||||
break;
|
||||
case self::SELF_CHOOSE:
|
||||
$departmentIds = array_merge(array_column($role->getDepartments()->toArray(), 'id'));
|
||||
$uids = array_merge($uids, Users::getUserIdsByDepartmentIds($departmentIds));
|
||||
break;
|
||||
case self::SELF_DATA:
|
||||
$uids[] = $user->id;
|
||||
break;
|
||||
case self::DEPARTMENT_DOWN_DATA:
|
||||
case self::DEPARTMENT_DATA:
|
||||
$uids = array_merge($uids, Users::getUserIdsByDepartmentIds([$user->department_id]));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 如果有全部数据 直接跳出
|
||||
if ($isAll) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $uids;
|
||||
}
|
||||
}
|
85
catch/permissions/model/Users.php
Normal file
85
catch/permissions/model/Users.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model;
|
||||
|
||||
use catchAdmin\permissions\model\search\UserSearch;
|
||||
use catcher\base\CatchModel;
|
||||
|
||||
class Users extends CatchModel
|
||||
{
|
||||
use HasRolesTrait;
|
||||
use HasJobsTrait;
|
||||
use UserSearch;
|
||||
|
||||
protected $name = 'users';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'username', // 用户名
|
||||
'password', // 用户密码
|
||||
'email', // 邮箱 登录
|
||||
'creator_id', // 创建者ID
|
||||
'department_id', // 部门ID
|
||||
'status', // 用户状态 1 正常 2 禁用
|
||||
'last_login_ip', // 最后登录IP
|
||||
'last_login_time', // 最后登录时间
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 删除状态,0未删除 >0 已删除
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* set password
|
||||
*
|
||||
* @time 2019年12月07日
|
||||
* @param $value
|
||||
* @return false|string
|
||||
*/
|
||||
public function setPasswordAttr($value)
|
||||
{
|
||||
return password_hash($value, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public function getList(): \think\Paginator
|
||||
{
|
||||
return $this->withoutField(['updated_at'], true)
|
||||
->catchSearch()
|
||||
->catchLeftJoin(Department::class, 'id', 'department_id', ['department_name'])
|
||||
->order($this->getTable() . '.id', 'desc')
|
||||
->paginate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限
|
||||
*
|
||||
* @time 2019年12月12日
|
||||
* @param $uid
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissionsBy($uid = 0): array
|
||||
{
|
||||
// 获取超级管理配置 超级管理员全部权限
|
||||
if ($uid == config('catch.permissions.super_admin_id')) {
|
||||
return Permissions::select()->column('id');
|
||||
}
|
||||
|
||||
$roles = $uid ? $this->findBy($uid)->getRoles() : $this->getRoles();
|
||||
|
||||
$permissionIds = [];
|
||||
foreach ($roles as $role) {
|
||||
$permissionIds = array_merge($permissionIds, $role->getPermissions()->column('id'));
|
||||
}
|
||||
|
||||
return array_unique($permissionIds);
|
||||
}
|
||||
}
|
15
catch/permissions/model/search/DepartmentSearch.php
Normal file
15
catch/permissions/model/search/DepartmentSearch.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
trait DepartmentSearch
|
||||
{
|
||||
public function searchDepartmentNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('department_name', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('status', $value);
|
||||
}
|
||||
}
|
20
catch/permissions/model/search/JobsSearch.php
Normal file
20
catch/permissions/model/search/JobsSearch.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
trait JobsSearch
|
||||
{
|
||||
public function searchJobNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('job_name', $value);
|
||||
}
|
||||
|
||||
public function searchCodingAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('coding', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where('status', $value);
|
||||
}
|
||||
}
|
31
catch/permissions/model/search/PermissionsSearch.php
Normal file
31
catch/permissions/model/search/PermissionsSearch.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
use catchAdmin\permissions\model\Roles;
|
||||
|
||||
trait PermissionsSearch
|
||||
{
|
||||
public function searchPermissionNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('permission_name', $value);
|
||||
}
|
||||
|
||||
public function searchIdAttr($query, $value, $data)
|
||||
{
|
||||
$query->where('parent_id', $value)->whereOr('id', $value);
|
||||
}
|
||||
|
||||
public function searchRoleIdAttr($query, $value, $data)
|
||||
{
|
||||
$permissionIds = [];
|
||||
$permissions = Roles::where('id', $value)->find()->getPermissions();
|
||||
|
||||
foreach ($permissions as $_permission) {
|
||||
$permissionIds[] = $_permission->pivot->permission_id;
|
||||
}
|
||||
|
||||
if(!empty($permissionIds)) {
|
||||
$query->whereIn('id', $permissionIds);
|
||||
}
|
||||
}
|
||||
}
|
16
catch/permissions/model/search/RolesSearch.php
Normal file
16
catch/permissions/model/search/RolesSearch.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
trait RolesSearch
|
||||
{
|
||||
public function searchRoleNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('role_name', $value);
|
||||
}
|
||||
|
||||
public function searchIdAttr($query, $value, $data)
|
||||
{
|
||||
$query->where('parent_id', $value)->whereOr('id', $value);
|
||||
}
|
||||
|
||||
}
|
25
catch/permissions/model/search/UserSearch.php
Normal file
25
catch/permissions/model/search/UserSearch.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace catchAdmin\permissions\model\search;
|
||||
|
||||
trait UserSearch
|
||||
{
|
||||
public function searchUsernameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('username', $value);
|
||||
}
|
||||
|
||||
public function searchEmailAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('email', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where($this->aliasField('status'), $value);
|
||||
}
|
||||
|
||||
public function searchDepartmentIdAttr($query, $value, $data)
|
||||
{
|
||||
return $query->where($this->aliasField('department_id'), $value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user