fix: [payroll] 급여 등록 500 에러 수정
- 중복 급여 등록 시 유니크 제약 위반 대신 422 응답 반환 - tenant_id null 방어 처리 (세션 값이 null인 경우 기본값 적용)
This commit is contained in:
@@ -62,7 +62,7 @@ class PayrollSetting extends Model
|
||||
|
||||
public function scopeForTenant($query, ?int $tenantId = null)
|
||||
{
|
||||
$tenantId = $tenantId ?? session('selected_tenant_id', 1);
|
||||
$tenantId = $tenantId ?? session('selected_tenant_id') ?? 1;
|
||||
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public function scopeForTenant($query, ?int $tenantId = null)
|
||||
|
||||
public static function getOrCreate(?int $tenantId = null): self
|
||||
{
|
||||
$tenantId = $tenantId ?? session('selected_tenant_id', 1);
|
||||
$tenantId = $tenantId ?? session('selected_tenant_id') ?? 1;
|
||||
|
||||
return self::firstOrCreate(
|
||||
['tenant_id' => $tenantId],
|
||||
|
||||
Reference in New Issue
Block a user