2025-10-13 21:52:34 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Orders;
|
|
|
|
|
|
2026-01-29 15:33:54 +09:00
|
|
|
use App\Traits\Auditable;
|
2025-10-13 21:52:34 +09:00
|
|
|
use App\Traits\BelongsToTenant;
|
|
|
|
|
use App\Traits\ModelTrait;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
|
|
class ClientGroup extends Model
|
|
|
|
|
{
|
2026-01-29 15:33:54 +09:00
|
|
|
use Auditable, BelongsToTenant, ModelTrait, SoftDeletes;
|
2025-10-13 21:52:34 +09:00
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'tenant_id',
|
|
|
|
|
'group_code',
|
|
|
|
|
'group_name',
|
|
|
|
|
'price_rate',
|
|
|
|
|
'is_active',
|
|
|
|
|
'created_by',
|
|
|
|
|
'updated_by',
|
|
|
|
|
'deleted_by',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'price_rate' => 'decimal:4',
|
|
|
|
|
'is_active' => 'boolean',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Clients 관계
|
|
|
|
|
public function clients()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Client::class, 'client_group_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 스코프
|
|
|
|
|
public function scopeActive($query)
|
|
|
|
|
{
|
|
|
|
|
return $query->where('is_active', 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function scopeCode($query, string $code)
|
|
|
|
|
{
|
|
|
|
|
return $query->where('group_code', $code);
|
|
|
|
|
}
|
|
|
|
|
}
|