67 lines
1.3 KiB
PHP
67 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Barobill;
|
|
|
|
use App\Models\Tenants\Tenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* 계정과목 모델
|
|
*/
|
|
class AccountCode extends Model
|
|
{
|
|
protected $table = 'account_codes';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'code',
|
|
'name',
|
|
'category',
|
|
'sort_order',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
'sort_order' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 테넌트 관계
|
|
*/
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
|
|
/**
|
|
* 테넌트별 활성 계정과목 조회 (하위 호환용)
|
|
*/
|
|
public static function getActiveByTenant(int $tenantId)
|
|
{
|
|
return self::getActive();
|
|
}
|
|
|
|
/**
|
|
* 전체 활성 계정과목 조회 (글로벌)
|
|
*/
|
|
public static function getActive()
|
|
{
|
|
return self::where('is_active', true)
|
|
->orderBy('sort_order')
|
|
->orderBy('code')
|
|
->get();
|
|
}
|
|
|
|
/**
|
|
* 전체 계정과목 조회 (글로벌)
|
|
*/
|
|
public static function getAll()
|
|
{
|
|
return self::orderBy('sort_order')
|
|
->orderBy('code')
|
|
->get();
|
|
}
|
|
}
|