- Position 모델 생성 (type: rank | title) - PositionService: CRUD + reorder 구현 - PositionController: REST API 엔드포인트 - Swagger 문서 작성 (PositionApi.php) - 마이그레이션: positions 테이블 + common_codes 등록 - routes/api.php에 라우트 등록 Phase L-3 (직급관리), L-4 (직책관리) 백엔드 완료 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
1.7 KiB
PHP
75 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Tenants;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use App\Traits\ModelTrait;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* 직급/직책 통합 모델
|
|
*
|
|
* @property int $id
|
|
* @property int $tenant_id
|
|
* @property string $type rank(직급) | title(직책)
|
|
* @property string $name 명칭
|
|
* @property int $sort_order 정렬 순서
|
|
* @property bool $is_active 활성화 여부
|
|
*/
|
|
class Position extends Model
|
|
{
|
|
use BelongsToTenant, ModelTrait, SoftDeletes;
|
|
|
|
protected $table = 'positions';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'type',
|
|
'name',
|
|
'sort_order',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'tenant_id' => 'int',
|
|
'sort_order' => 'int',
|
|
'is_active' => 'bool',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'deleted_at',
|
|
];
|
|
|
|
// =========================================================================
|
|
// 상수
|
|
// =========================================================================
|
|
|
|
public const TYPE_RANK = 'rank'; // 직급
|
|
|
|
public const TYPE_TITLE = 'title'; // 직책
|
|
|
|
// =========================================================================
|
|
// 스코프
|
|
// =========================================================================
|
|
|
|
public function scopeRanks($query)
|
|
{
|
|
return $query->where('type', self::TYPE_RANK);
|
|
}
|
|
|
|
public function scopeTitles($query)
|
|
{
|
|
return $query->where('type', self::TYPE_TITLE);
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
|
|
public function scopeOrdered($query)
|
|
{
|
|
return $query->orderBy('sort_order');
|
|
}
|
|
} |