Files
sam-api/app/Models/Tenants/Position.php
kent d6e18fb54e feat(API): 직책/직원/근태 관리 API 개선
- Position 모델: key 필드 추가 및 마이그레이션
- PositionSeeder: 기본 직책 시더 추가
- TenantUserProfile: 프로필 이미지 관련 필드 추가
- Employee Request: 직원 등록/수정 요청 검증 강화
- EmployeeService: 직원 관리 서비스 로직 개선
- AttendanceService: 근태 관리 서비스 개선

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 17:25:13 +09:00

77 lines
1.8 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|null $key 영문 키 (tenant_user_profiles 연동용)
* @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',
'key',
'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');
}
}