<?php

namespace App\Modules\OfficialAccount\Models;

use Illuminate\Database\Eloquent\Model;

class CustomMsgSwitchsMsgs extends Model
{
    protected $tables = 'custom_msg_switchs_msgs';

    protected $fillable = ['status','distribution_channel_id','custom_category','is_self_content'];

    /**
     * 获取指定客服消息开关
     */
    static function customMsgSwitchsByChannelCate($distribution_channel_id,$custom_category)
    {
        
        return self::where(['distribution_channel_id'=>$distribution_channel_id,'custom_category'=>$custom_category])->first();
    
    }


    /**
     * 根据distribution_channel_id获取所有客服消息开关
     */
    static function customMsgSwitchsMsgsByChannelId($distribution_channel_id)
    {
        
        return self::where('distribution_channel_id',$distribution_channel_id)->get();
    
    }


    function customMsgSwitchs(){

        return $this->hasOne('App\Modules\OfficialAccount\Models\CustomMsgSwitchs','custom_category','custom_category');
    
    }

}


