update fix deadcode, security

This commit is contained in:
baodev0
2026-09-28 08:26:29 +07:00
parent 3af59bd9c5
commit 82080b5b84
452 changed files with 4857 additions and 26289 deletions
@@ -15,7 +15,6 @@ class TicketRepository extends BaseRepository implements TicketRepositoryInterfa
{
$model = $this->model->with($relationships)->select($select);
if (isset($data['status']) && ! empty($data['status']) && $data['status'] != 'full') {
$model = $model->where("status", match (strtolower($data['status'])) {
'pending' => 1,
@@ -28,61 +27,10 @@ class TicketRepository extends BaseRepository implements TicketRepositoryInterfa
$model = $model->withCount($withCount);
}
if (isset($data['page']) && $data['page']) {
return $model->paginate(15);
}
return $model->get();
}
public function findWithRelationshipsByKey(string $key = '', string|int $value = '', array $relationships = [], array $withCount = [], array $withSum = [])
{
if (empty($key) || empty($value)) {
return false;
}
$model = $this->model;
if (count($relationships) > 0) {
foreach ($relationships as $relationship) {
if (method_exists($model, $relationship)) {
$model = $model->with($relationship);
}
}
}
// Xử lý withCount
if (count($withCount) > 0) {
foreach ($withCount as $key => $items) {
if (is_array($items)) {
foreach ($items as $alias => $item) {
$model = $model->withCount([
$key . ' as ' . $alias => function ($query) use ($item) {
$query->where($item['key'], $item['condition'], $item['value']);
}
]);
}
} else {
$model = $model->withCount($key);
}
}
}
// Xử lý withSum
if (count($withSum) > 0) {
foreach ($withSum as $key => $items) {
if (is_array($items)) {
foreach ($items as $alias => $item) {
$model = $model->withSum([
$key . ' as ' . $alias => function ($query) use ($item) {
$query->where($item['key'], $item['condition'], $item['value']);
}
], $item['sum']);
}
} else {
$model = $model->withSum($key);
}
}
}
return $model->where($key, $value)->latest('id')->get();
}
public function findBy(string $key = '', string $value)
{
if (empty($key) || empty($value)) {
@@ -90,11 +38,4 @@ class TicketRepository extends BaseRepository implements TicketRepositoryInterfa
}
return $this->model->where($key, $value)->first();
}
public function updateBy(string $key = '', string $value = '', array $data = [])
{
if (empty($key) || empty($value) || count($data) < 1) {
return false;
}
return $this->model->where($key, $value)->update($data);
}
}