feat(api-explorer): Phase 1 기본 구조 및 OpenAPI 파싱 구현
- Config: api-explorer.php (환경, 보안, 캐시 설정) - Migration: api_bookmarks, api_templates, api_histories, api_environments - Model: ApiBookmark, ApiTemplate, ApiHistory, ApiEnvironment - Service: OpenApiParserService, ApiRequestService, ApiExplorerService - Controller: ApiExplorerController (CRUD, 실행, 히스토리) - View: 3-Panel 레이아웃 (sidebar, request, response, history) - Route: 23개 엔드포인트 등록 Swagger UI 대체 개발 도구, HTMX 기반 SPA 경험
This commit is contained in:
67
app/Models/DevTools/ApiBookmark.php
Normal file
67
app/Models/DevTools/ApiBookmark.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\DevTools;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* API 즐겨찾기 모델
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $endpoint
|
||||
* @property string $method
|
||||
* @property string|null $display_name
|
||||
* @property int $display_order
|
||||
* @property string|null $color
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
*/
|
||||
class ApiBookmark extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'endpoint',
|
||||
'method',
|
||||
'display_name',
|
||||
'display_order',
|
||||
'color',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'display_order' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 사용자 관계
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본 정렬 스코프
|
||||
*/
|
||||
public function scopeOrdered($query)
|
||||
{
|
||||
return $query->orderBy('display_order')->orderBy('created_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP 메서드 배지 색상
|
||||
*/
|
||||
public function getMethodColorAttribute(): string
|
||||
{
|
||||
return match (strtoupper($this->method)) {
|
||||
'GET' => 'green',
|
||||
'POST' => 'blue',
|
||||
'PUT' => 'yellow',
|
||||
'PATCH' => 'orange',
|
||||
'DELETE' => 'red',
|
||||
default => 'gray',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user