- 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/*)
62 lines
1.3 KiB
PHP
62 lines
1.3 KiB
PHP
<?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');
|
|
}
|
|
}
|