95 lines
2.4 KiB
PHP
95 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* メールテンプレートモデル - mail_templateテーブル
|
|
*
|
|
* メール送信テンプレート情報を管理するモデル
|
|
* 使用プログラムIDに基づいてテンプレートを取得し、メール送信処理で使用される
|
|
*/
|
|
class MailTemplate extends Model
|
|
{
|
|
protected $table = 'mail_template';
|
|
protected $primaryKey = 'mail_template_id';
|
|
public $timestamps = true;
|
|
|
|
const CREATED_AT = 'created_at';
|
|
const UPDATED_AT = 'updated_at';
|
|
|
|
protected $fillable = [
|
|
'pg_id', // 使用プログラムID
|
|
'internal_id', // 内部ID
|
|
'mgr_cc_flag', // エリアマネージャー同報フラグ
|
|
'bcc_adrs', // BCCアドレス
|
|
'use_flag', // 使用フラグ
|
|
'memo', // メモ
|
|
'subject', // 件名
|
|
'text', // 本文
|
|
'operator_id' // オペレータID
|
|
];
|
|
|
|
protected $casts = [
|
|
'mgr_cc_flag' => 'boolean',
|
|
'use_flag' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* 使用プログラムIDでメールテンプレート情報を取得
|
|
*
|
|
* 仕様書に基づく検索条件:
|
|
* - 使用プログラムID = 入力パラメーター
|
|
* - 使用フラグ = 1
|
|
*
|
|
* @param int $pgId 使用プログラムID
|
|
* @return MailTemplate|null メールテンプレート情報
|
|
*/
|
|
public static function getByProgramId(int $pgId): ?MailTemplate
|
|
{
|
|
return self::where('pg_id', $pgId)
|
|
->where('use_flag', 1)
|
|
->first();
|
|
}
|
|
|
|
/**
|
|
* エリアマネージャー同報が有効かチェック
|
|
*
|
|
* @return bool エリアマネージャー同報フラグ
|
|
*/
|
|
public function isManagerCcEnabled(): bool
|
|
{
|
|
return (bool) $this->mgr_cc_flag;
|
|
}
|
|
|
|
/**
|
|
* BCCアドレスを取得
|
|
*
|
|
* @return string|null BCCアドレス
|
|
*/
|
|
public function getBccAddress(): ?string
|
|
{
|
|
return $this->bcc_adrs;
|
|
}
|
|
|
|
/**
|
|
* メール件名を取得
|
|
*
|
|
* @return string|null メール件名
|
|
*/
|
|
public function getSubject(): ?string
|
|
{
|
|
return $this->subject;
|
|
}
|
|
|
|
/**
|
|
* メール本文を取得
|
|
*
|
|
* @return string|null メール本文
|
|
*/
|
|
public function getText(): ?string
|
|
{
|
|
return $this->text;
|
|
}
|
|
} |