Files
Gnuboard7/plugins/_bundled/sirsoft-message_bizppurio/src/Models/BizppurioNotificationBinding.php
T
chym1217 77df8c9a7c feat(message_bizppurio): 발송 결과 기록 + webhook 수신 + 결과코드
문자·알림톡 발송 결과를 DB에 기록하고, 비즈뿌리오 webhook(URL PUSH)으로
도달 여부를 갱신한다. 결과코드를 사유+분류로 해석하고, 잔액 부족 시
관리자에게 쿨다운(기본 1시간) 내 1회만 알린다.

발송 결과를 확인하는 화면은 플러그인 독립 페이지 대신 코어 알림 이력에
얹는 방식(후속)으로 이관하기로 하여, 이번에 만든 독립 이력 화면과
화면 전용 백엔드는 제거했다. webhook 결과 저장·수신·해석 뼈대는 유지한다.
2026-07-28 12:36:21 +09:00

88 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Plugins\Sirsoft\MessageBizppurio\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Plugins\Sirsoft\MessageBizppurio\Enums\DispatchChannel;
/**
* 비즈뿌리오 이벤트↔알림톡 템플릿 연결(설정) 모델.
*
* "어느 알림에 어느 알림톡 템플릿을 쓸지 + 대체발송 여부"를 저장한다.
* 알림 설정 알림톡 탭 편집 모달(계획서 §6-2)이 우리 API 로 저장하고,
* 알림톡 채널 드라이버(Phase 6)가 이 연결을 조회해 발송 대상 템플릿을 결정한다.
*
* @property int $id
* @property string $notification_type
* @property string $channel
* @property string $template_code
* @property string $template_name
* @property bool $fallback_sms_enabled
* @property bool $is_active
* @property \Carbon\Carbon|null $created_at
* @property \Carbon\Carbon|null $updated_at
*/
class BizppurioNotificationBinding extends Model
{
/**
* 테이블명
*
* @var string
*/
protected $table = 'bizppurio_notification_bindings';
/**
* 대량 할당 허용 필드
*
* @var array<int, string>
*/
protected $fillable = [
'notification_type',
'channel',
'template_code',
'template_name',
'fallback_sms_enabled',
'is_active',
];
/**
* 속성 캐스팅 정의
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'channel' => DispatchChannel::class,
'fallback_sms_enabled' => 'boolean',
'is_active' => 'boolean',
];
}
/**
* 활성 연동만 조회하는 스코프.
*
* @param Builder $query
* @return Builder
*/
public function scopeActive(Builder $query): Builder
{
return $query->where('is_active', true);
}
/**
* 알림 유형으로 조회하는 스코프 (발송 시 template_code 해석).
*
* @param Builder $query
* @param string $notificationType 코어 notification_definitions.type
* @return Builder
*/
public function scopeByNotificationType(Builder $query, string $notificationType): Builder
{
return $query->where('notification_type', $notificationType);
}
}