major update
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace MintyPHP\Repository\Tenant;
|
||||
|
||||
use MintyPHP\Domain\Taxonomy\TenantStatus;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
@@ -81,7 +82,7 @@ class TenantRepository
|
||||
$rows = call_user_func_array(
|
||||
['MintyPHP\\DB', 'select'],
|
||||
array_merge(
|
||||
["select id from tenants where status = 'active' and id in ($placeholders)"],
|
||||
["select id from tenants where status = ? and id in ($placeholders)", TenantStatus::Active->value],
|
||||
$params
|
||||
)
|
||||
);
|
||||
@@ -101,6 +102,7 @@ class TenantRepository
|
||||
public function listPaged(array $options): array
|
||||
{
|
||||
$search = trim((string) ($options['search'] ?? ''));
|
||||
$status = TenantStatus::tryNormalize((string) ($options['status'] ?? ''));
|
||||
$allowedOrder = ['id', 'uuid', 'description', 'status', 'created', 'modified'];
|
||||
[$limit, $offset] = RepoQuery::sanitizeLimitOffset($options);
|
||||
[$order, $dir] = RepoQuery::sanitizeOrder($options, $allowedOrder);
|
||||
@@ -108,6 +110,10 @@ class TenantRepository
|
||||
$where = [];
|
||||
$params = [];
|
||||
RepoQuery::addLikeFilter($where, $params, ['description', 'uuid'], $search);
|
||||
if ($status !== null) {
|
||||
$where[] = 'tenants.status = ?';
|
||||
$params[] = $status->value;
|
||||
}
|
||||
if (!empty($options['tenantUserId'])) {
|
||||
$tenantUserId = (int) $options['tenantUserId'];
|
||||
if ($tenantUserId > 0) {
|
||||
@@ -187,7 +193,7 @@ class TenantRepository
|
||||
$data['primary_color'] ?? null,
|
||||
$data['default_theme'] ?? null,
|
||||
$data['allow_user_theme'] ?? null,
|
||||
$data['status'] ?? 'active',
|
||||
$data['status'] ?? TenantStatus::Active->value,
|
||||
$data['status_changed_at'] ?? null,
|
||||
$data['status_changed_by'] ?? null,
|
||||
$data['created_by'] ?? null
|
||||
@@ -217,7 +223,7 @@ class TenantRepository
|
||||
'primary_color' => $data['primary_color'] ?? null,
|
||||
'default_theme' => $data['default_theme'] ?? null,
|
||||
'allow_user_theme' => $data['allow_user_theme'] ?? null,
|
||||
'status' => $data['status'] ?? 'active',
|
||||
'status' => $data['status'] ?? TenantStatus::Active->value,
|
||||
];
|
||||
if (array_key_exists('modified_by', $data)) {
|
||||
$fields['modified_by'] = $data['modified_by'];
|
||||
|
||||
Reference in New Issue
Block a user