- config/database.php에 codebridge connection 추가 - 78개 MNG 전용 모델에 $connection = 'codebridge' 설정 - Admin (15): PM, 로드맵, API Explorer - Sales (16): 영업파트너, 수수료, 가망고객 - Finance (9): 법인카드, 자금관리, 홈택스 - Barobill (12): 은행/카드 동기화 관리 - Interview (1), ESign (6), Equipment (2) - AI (3), Audit (3), 기타 (11)
73 lines
1.5 KiB
PHP
73 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Sales;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* 영업 상품 카테고리 모델
|
|
*
|
|
* @property int $id
|
|
* @property string $code
|
|
* @property string $name
|
|
* @property string|null $description
|
|
* @property string $base_storage
|
|
* @property int $display_order
|
|
* @property bool $is_active
|
|
*/
|
|
class SalesProductCategory extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $connection = 'codebridge';
|
|
protected $table = 'sales_product_categories';
|
|
|
|
protected $fillable = [
|
|
'code',
|
|
'name',
|
|
'description',
|
|
'base_storage',
|
|
'display_order',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'display_order' => 'integer',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* 상품 관계
|
|
*/
|
|
public function products(): HasMany
|
|
{
|
|
return $this->hasMany(SalesProduct::class, 'category_id');
|
|
}
|
|
|
|
/**
|
|
* 활성 상품만
|
|
*/
|
|
public function activeProducts(): HasMany
|
|
{
|
|
return $this->products()->where('is_active', true)->orderBy('display_order');
|
|
}
|
|
|
|
/**
|
|
* 활성 카테고리 스코프
|
|
*/
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
|
|
/**
|
|
* 정렬 스코프
|
|
*/
|
|
public function scopeOrdered($query)
|
|
{
|
|
return $query->orderBy('display_order')->orderBy('name');
|
|
}
|
|
}
|