feat: 견적 단가 자동 적용 기능 추가
- 고객 그룹별 단가 조정 지원 - 견적 생성 시 자동 단가 조회 - 매출단가만 사용 (매입단가는 경고)
This commit is contained in:
51
app/Models/Orders/Client.php
Normal file
51
app/Models/Orders/Client.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Orders;
|
||||
|
||||
use App\Traits\BelongsToTenant;
|
||||
use App\Traits\ModelTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Client extends Model
|
||||
{
|
||||
use BelongsToTenant, ModelTrait;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'client_group_id',
|
||||
'client_code',
|
||||
'name',
|
||||
'contact_person',
|
||||
'phone',
|
||||
'email',
|
||||
'address',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
// ClientGroup 관계
|
||||
public function clientGroup()
|
||||
{
|
||||
return $this->belongsTo(ClientGroup::class, 'client_group_id');
|
||||
}
|
||||
|
||||
// Orders 관계
|
||||
public function orders()
|
||||
{
|
||||
return $this->hasMany(Order::class, 'client_id');
|
||||
}
|
||||
|
||||
// 스코프
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('is_active', 'Y');
|
||||
}
|
||||
|
||||
public function scopeCode($query, string $code)
|
||||
{
|
||||
return $query->where('client_code', $code);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user