whereLike('role_name', '%' . $where['role_name'] . '%'); } if (isset($where['status'])) { $roleModel = $roleModel->where('status', intval($where['status'])); } return $roleModel->where('mer_id', $merId); } /** * @param int $merId * @return array * @author zfy * @day 2020-04-18 */ public function getAllOptions(int $merId) { return Role::getDB()->where('status', 1)->where('mer_id', $merId)->column('role_name', 'role_id'); } /** * @param $merId * @param array $ids * @return array * @author zfy * @day 2020-04-18 */ public function idsByRules($merId, array $ids) { $rules = Role::getDB()->where('status', 1)->where('mer_id', $merId)->whereIn($this->getPk(), $ids)->column('rules'); $data = []; foreach ($rules as $rule) { $data = array_merge(explode(',', $rule), $data); } return array_unique($data); } /** * @param int $merId * @param int $id * @return bool * @author zfy * @day 2020-04-18 */ public function merExists(int $merId, int $id) { return Role::getDB()->where($this->getPk(), $id)->where('mer_id', $merId)->count() > 0; } }