Update source into github

This commit is contained in:
pbao9
2025-07-24 16:18:27 +07:00
parent 41419358dd
commit 69851ac7bc
2642 changed files with 284095 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Repositories\Log;
use App\Models\Log;
use App\Repositories\BaseRepository;
class LogRepository extends BaseRepository implements LogRepositoryInterface
{
public function getModel()
{
return Log::class;
}
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
{
$model = $this->model->with($relationships)->select($select);
if (isset($data['customer_id'])) {
$model = $model->where("customer_id", $data['customer_id']);
}
if (isset($data['relations'])) {
foreach ($data['relations'] as $key => $value) {
$model = $model->whereHas($key, function ($query) use ($value) {
if (isset($value['condition'])) {
switch (strtoupper($value['condition'])) {
case "IN":
$query->whereIn($value['key'], $value['value']);
break;
case "NotIn":
$query->whereNotIn($value['key'], $value['value']);
break;
default:
$query->where($value['key'], $value['condition'], $value['value']);
break;
}
} else {
$query->where($value['key'], $value['value']);
}
});
}
}
if (count($withCount) > 0) {
$model = $model->withCount($withCount);
}
if(isset($data['limit']))
{
return $model->latest('id')->take($data['limit'])->get();
}
if(isset($data['page'])) {
return $model->latest('id')->paginate(15);
}
return $model->latest('id')->get();
}
}