Files
sam-manage/app/Models/Barobill/Client.php
김보곤 69f117ef8e fix:거래처코드 검색을 고유번호(id) 기반으로 변경
- Client::searchByCodeOrName → searchByIdOrName으로 변경
- 검색 기준: id(숫자일 때 정확 매칭) + name(LIKE 검색)
- 반환값: client_code 대신 id를 code로 반환

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 21:25:08 +09:00

34 lines
912 B
PHP

<?php
namespace App\Models\Barobill;
use Illuminate\Database\Eloquent\Model;
/**
* 거래처 모델 (검색용)
* clients 테이블은 API 프로젝트에서 관리하며, MNG에서는 검색 조회만 수행
*/
class Client extends Model
{
protected $table = 'clients';
/**
* 고유번호(id) 또는 거래처명으로 검색
*/
public static function searchByIdOrName(int $tenantId, string $keyword, int $limit = 20)
{
return self::where('tenant_id', $tenantId)
->where('is_active', true)
->where(function ($query) use ($keyword) {
if (is_numeric($keyword)) {
$query->where('id', $keyword);
}
$query->orWhere('name', 'like', "%{$keyword}%");
})
->select('id', 'name')
->orderBy('id')
->limit($limit)
->get();
}
}