TASK-290 Add new new command for Auth Sources Cron
This commit is contained in:
@@ -35,11 +35,11 @@ class Department extends Model
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']['text'])) {
|
||||
$query->where('DEP_TITLE', 'like', '%' . $filters['conditions']['text'] . '%');
|
||||
unset($filters['conditions']['text']);
|
||||
@@ -49,13 +49,13 @@ class Department extends Model
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
|
||||
@@ -133,4 +133,83 @@ class GroupUser extends Model
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function show($filters = array())
|
||||
{
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => $total,
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getUsersByGroupId($groupUid, $filters = [])
|
||||
{
|
||||
$query = static::query();
|
||||
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
$query->where('GROUP_USER.GRP_UID', $groupUid);
|
||||
$query->innerJoin('GROUP_USER.USR_UID', '=', 'USERS.USR_UID');
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => $total,
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function removeGroupUser($conditions)
|
||||
{
|
||||
try {
|
||||
$responseSave = GroupUser::where($conditions)
|
||||
->delete();
|
||||
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ class Groupwf extends Model
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']['text'])) {
|
||||
$query->where('GRP_TITLE', 'like', '%' . $filters['conditions']['text'] . '%');
|
||||
unset($filters['conditions']['text']);
|
||||
@@ -44,13 +44,13 @@ class Groupwf extends Model
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,11 @@ class RbacAuthenticationSource extends Model
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']['text'])) {
|
||||
$query->where('AUTH_SOURCE_NAME', 'like', '%' . $filters['conditions']['text'] . '%');
|
||||
unset($filters['conditions']['text']);
|
||||
@@ -48,13 +48,13 @@ class RbacAuthenticationSource extends Model
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
|
||||
@@ -20,23 +20,23 @@ class RbacUsers extends Model
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
@@ -96,6 +96,17 @@ class RbacUsers extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateDataFromListUsersUids($userData, $usersUids = [])
|
||||
{
|
||||
try {
|
||||
$responseSave = self::whereIn('USR_UID', $usersUids)
|
||||
->update($userData);
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if username exists
|
||||
*
|
||||
|
||||
@@ -18,6 +18,79 @@ class User extends Model
|
||||
// Our custom timestamp columns
|
||||
const CREATED_AT = 'USR_CREATE_DATE';
|
||||
const UPDATED_AT = 'USR_UPDATE_DATE';
|
||||
public function show($filters = array())
|
||||
{
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => $total,
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function getByListUids($listUids, $filters = array())
|
||||
{
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$query->whereIn('USR_UID', $listUids);
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => $total,
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the delegations this user has (all of them)
|
||||
@@ -317,4 +390,31 @@ class User extends Model
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function updateData($userData, $conditions = [])
|
||||
{
|
||||
try {
|
||||
$responseSave = self::where($conditions)
|
||||
->update($userData);
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateDataFromListUsersUids($userData, $usersUids = [], $extraConditions = [])
|
||||
{
|
||||
try {
|
||||
$query = self::whereIn('USR_UID', $usersUids);
|
||||
|
||||
if (!empty($extraConditions) && is_array($extraConditions)) {
|
||||
$query->where($extraConditions);
|
||||
}
|
||||
|
||||
$responseSave = $query->update($userData);
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user