- Config, Service, Controller, View 생성 - Model 4개 (admin_api_* 테이블 참조) - 3-Panel 레이아웃 (sidebar, request, response) - HTMX 기반 동적 UI - 마이그레이션은 api/ 프로젝트에서 관리
70 lines
1.5 KiB
PHP
70 lines
1.5 KiB
PHP
<?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 $table = 'admin_api_bookmarks';
|
|
|
|
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',
|
|
};
|
|
}
|
|
}
|