<?php

namespace App\Modules\Activity\Models;

use Illuminate\Database\Eloquent\Model;

class ActivitySwitch extends Model
{
	protected $connection = 'api_mysql';
	
    protected $table = 'activity_show_switch';
    protected $fillable = ['id', 'activity_id', 'distribution_channel_id', 'is_reader_page_show', 'is_sign_message_show', 'created_at', 'updated_at'];

    //更新活动显示开关
    static function updateShowSwitch($activity_id, $distribution_channel_id, $is_reader_page_show, $is_sign_message_show)
    {
        $search_obj = self::where('activity_id', $activity_id)->where('distribution_channel_id', $distribution_channel_id);
        return $search_obj->update(['is_reader_page_show' => $is_reader_page_show, 'is_sign_message_show' => $is_sign_message_show]);
    }

    static function add($data)
    {
        return self::create($data);
    }

    static function getInfo($activity_id, $distribution_channel_id)
    {
        return self::where('activity_id', $activity_id)->where('distribution_channel_id', $distribution_channel_id)->first();
    }

}