fix : Tenant API 추가
- 테넌트 목록 조회 - 테넌트 정보 조회 - 테넌트 정보 수정 - 테넌트 등록 - 테넌트 삭제 - 테넌트 복구
This commit is contained in:
@@ -25,17 +25,19 @@ public static function debugQueryLog(): array
|
||||
{
|
||||
$logs = DB::getQueryLog();
|
||||
|
||||
return collect($logs)->map(function ($log) {
|
||||
$query = $log['query'];
|
||||
foreach ($log['bindings'] as $binding) {
|
||||
$binding = is_numeric($binding) ? $binding : "'" . addslashes($binding) . "'";
|
||||
$query = preg_replace('/\\?/', $binding, $query, 1);
|
||||
}
|
||||
return collect($logs)
|
||||
->skip(3)
|
||||
->map(function ($log) {
|
||||
$query = $log['query'];
|
||||
foreach ($log['bindings'] as $binding) {
|
||||
$binding = is_numeric($binding) ? $binding : "'" . addslashes($binding) . "'";
|
||||
$query = preg_replace('/\\?/', $binding, $query, 1);
|
||||
}
|
||||
|
||||
// \n 제거
|
||||
$query = str_replace(["\n", "\r"], ' ', $query)." (time: {$log['time']})";
|
||||
return trim($query);
|
||||
})->toArray();
|
||||
// \n 제거
|
||||
$query = str_replace(["\n", "\r"], ' ', $query)." (time: {$log['time']})";
|
||||
return trim($query);
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
# ApiResponse Helper
|
||||
@@ -79,8 +81,7 @@ public static function validate(
|
||||
|
||||
public static function response($type = '', $query = '', $key = ''): array
|
||||
{
|
||||
$debug = (app()->environment('local')) ? true : false;
|
||||
if ($debug) DB::enableQueryLog(); // 쿼리 추적
|
||||
$debug = app()->environment('local') && request()->is('api/*');
|
||||
|
||||
$result = match ($type) {
|
||||
'get' => $key ? $query->get()->keyBy($key) : $query->get(),
|
||||
@@ -103,7 +104,12 @@ public static function response($type = '', $query = '', $key = ''): array
|
||||
}
|
||||
|
||||
$response['data'] = $result;
|
||||
$response['query'] = ($debug) ? self::debugQueryLog() : [];
|
||||
$response['query'] = $debug ? self::debugQueryLog() : [];
|
||||
|
||||
// 다음 요청에 로그가 섞이지 않도록 비워준다 (로컬에서만 의미있음)
|
||||
if ($debug) {
|
||||
DB::flushQueryLog();
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user