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

use Illuminate\Database\Eloquent\Model;

/**
 * 广告转询盘任务
 * Class ReInquiryTask
 * @package App\Models\Inquiry
 */
class ReInquiryTask extends Model
{
    /**
     * @var string
     */
    protected $table = 'gl_re_inquiry_task';

    /**
     * 任务状态, 1:开启(默认), 0:关闭
     */
    const STATUS_OPEN = 1;
    const STATUS_CLOSE = 0;

    /**
     * 创建询盘任务
     * @param $id
     * @param $title
     * @param $industry
     * @param $ad_id
     * @param $ad_url
     * @param $ad_img
     * @param $num
     * @param int $status
     * @return ReInquiryTask
     */
    public static function createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status = self::STATUS_OPEN)
    {
        $self = self::where(['id' => $id])->first();
        if (empty($self))
            $self = new self();
        $self->title = $title;
        $self->industry = $industry;
        $self->ad_id = $ad_id;
        $self->ad_url = $ad_url;
        $self->ad_img = $ad_img;
        $self->num = $num;
        $self->status = $status;
        $self->save();
        return $self;
    }

    /**
     * @param $value
     * @return mixed
     */
    public function getTargetAttribute($value)
    {
        return json_decode($value, true);
    }
}