ReInquiryText.php 1.1 KB
<?php
/**
 * Created by PhpStorm.
 * User: zhl
 * Date: 2024/9/30
 * Time: 14:23
 */
namespace App\Models\Inquiry;

use Illuminate\Database\Eloquent\Model;

/**
 * 询盘内置文案
 * Class ReInquiryText
 * @package App\Models\Inquiry
 */
class ReInquiryText extends Model
{
    /**
     * @var string
     */
    protected $table = 'gl_re_inquiry_text';

    /**
     * 文案状态, 1:开启(默认), 2:禁用
     */
    const STATUS_USABLE = 1;
    const STATUS_DISABLE = 2;

    /**
     * 创建询盘内置文案
     * @param $id
     * @param $title
     * @param $content
     * @param int $status
     * @return ReInquiryText
     */
    public static function createText($id, $title, $content, $status = self::STATUS_USABLE)
    {
        $self = self::where(['id' => $id])->first();
        if (empty($self))  {
            $self = new self();
            // 同步 询盘文案,以ID为唯一值
            $self->id = $id;
        }
        $self->title = $title;
        $self->content = $content;
        $self->status = $status;
        $self->save();
        return $self;
    }

}