50 lines
980 B
PHP
50 lines
980 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\Barobill;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
use App\Models\Tenants\Tenant;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 계정과목 모델
|
||
|
|
*/
|
||
|
|
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::where('tenant_id', $tenantId)
|
||
|
|
->where('is_active', true)
|
||
|
|
->orderBy('sort_order')
|
||
|
|
->orderBy('code')
|
||
|
|
->get();
|
||
|
|
}
|
||
|
|
}
|