- 사용자 초대 API: role 문자열 지원 추가 (React 호환) - 알림 설정 API: 그룹 기반 계층 구조 구현 - notification_setting_groups 테이블 추가 - notification_setting_group_items 테이블 추가 - notification_setting_group_states 테이블 추가 - GET/PUT /api/v1/settings/notifications 엔드포인트 추가 - Pint 코드 스타일 정리
102 lines
2.6 KiB
PHP
102 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* 시스템 필드 정의 모델
|
|
*
|
|
* 각 소스 테이블(items, tenants, users)의 시스템 필드를 정의합니다.
|
|
* 테넌트별 item_fields 시딩 시 참조하는 마스터 데이터입니다.
|
|
*/
|
|
class SystemFieldDefinition extends Model
|
|
{
|
|
protected $fillable = [
|
|
'source_table',
|
|
'source_table_label',
|
|
'field_key',
|
|
'field_name',
|
|
'field_type',
|
|
'order_no',
|
|
'is_required',
|
|
'is_seed_default',
|
|
'default_value',
|
|
'options',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'order_no' => 'integer',
|
|
'is_required' => 'boolean',
|
|
'is_seed_default' => 'boolean',
|
|
'is_active' => 'boolean',
|
|
'options' => 'array',
|
|
];
|
|
|
|
/**
|
|
* 소스 테이블 목록 조회
|
|
*/
|
|
public static function getSourceTables(): Collection
|
|
{
|
|
return self::query()
|
|
->select('source_table', 'source_table_label')
|
|
->where('is_active', true)
|
|
->groupBy('source_table', 'source_table_label')
|
|
->orderBy('source_table')
|
|
->get();
|
|
}
|
|
|
|
/**
|
|
* 특정 소스 테이블의 필드 목록 조회
|
|
*/
|
|
public static function getFieldsFor(string $sourceTable, bool $onlyActive = true): Collection
|
|
{
|
|
$query = self::query()
|
|
->where('source_table', $sourceTable)
|
|
->orderBy('order_no');
|
|
|
|
if ($onlyActive) {
|
|
$query->where('is_active', true);
|
|
}
|
|
|
|
return $query->get();
|
|
}
|
|
|
|
/**
|
|
* 특정 소스 테이블의 기본 시딩 대상 필드 목록 조회
|
|
*/
|
|
public static function getSeedDefaultFieldsFor(string $sourceTable): Collection
|
|
{
|
|
return self::query()
|
|
->where('source_table', $sourceTable)
|
|
->where('is_active', true)
|
|
->where('is_seed_default', true)
|
|
->orderBy('order_no')
|
|
->get();
|
|
}
|
|
|
|
/**
|
|
* 특정 소스 테이블의 필드 수 조회
|
|
*/
|
|
public static function getFieldCountFor(string $sourceTable): int
|
|
{
|
|
return self::query()
|
|
->where('source_table', $sourceTable)
|
|
->where('is_active', true)
|
|
->count();
|
|
}
|
|
|
|
/**
|
|
* 모든 소스 테이블의 시스템 필드 키 목록
|
|
*/
|
|
public static function getAllSystemFieldKeys(string $sourceTable): array
|
|
{
|
|
return self::query()
|
|
->where('source_table', $sourceTable)
|
|
->pluck('field_key')
|
|
->toArray();
|
|
}
|
|
}
|