feat: [hr] 인사관리 사원관리 Phase 1 구현
- Employee, Position 모델 생성 (tenant_user_profiles, positions 테이블) - EmployeeService 생성 (CRUD, 통계, 필터/검색/페이지네이션) - 뷰 컨트롤러(HR/EmployeeController) + API 컨트롤러 생성 - Blade 뷰: index(통계카드+HTMX테이블), create, edit, show, partials/table - 라우트: web.php(/hr/employees/*), api.php(/admin/hr/employees/*)
This commit is contained in:
61
app/Models/HR/Position.php
Normal file
61
app/Models/HR/Position.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\HR;
|
||||
|
||||
use App\Traits\ModelTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Position extends Model
|
||||
{
|
||||
use ModelTrait;
|
||||
|
||||
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',
|
||||
];
|
||||
|
||||
public const TYPE_RANK = 'rank';
|
||||
|
||||
public const TYPE_TITLE = 'title';
|
||||
|
||||
// =========================================================================
|
||||
// 스코프
|
||||
// =========================================================================
|
||||
|
||||
public function scopeForTenant($query, ?int $tenantId = null)
|
||||
{
|
||||
$tenantId = $tenantId ?? session('selected_tenant_id');
|
||||
if ($tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function scopeRanks($query)
|
||||
{
|
||||
return $query->where('type', self::TYPE_RANK);
|
||||
}
|
||||
|
||||
public function scopeTitles($query)
|
||||
{
|
||||
return $query->where('type', self::TYPE_TITLE);
|
||||
}
|
||||
|
||||
public function scopeOrdered($query)
|
||||
{
|
||||
return $query->orderBy('sort_order');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user