<?php
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2018/3/22
 * Time: 下午6:00
 */

namespace App\Modules\Channel\Services;


use App\Modules\Channel\Models\ChannelActivities;
use App\Modules\Channel\Models\Company;
use DB;

class ChannelActivitiesService
{
    public static function getValidActivity($channel_id) {
        return ChannelActivities::where([
            ['begin_time','<=',date('Y-m-d H:i:s')],
            ['end_time','>=',date('Y-m_d H:i:s')],
            ['distribution_channel_id','=',$channel_id]
        ])->first();
    }

    public static function addChannelActivity($channel_id,$param){
        $param['distribution_channel_id'] = $channel_id;
        return ChannelActivities::create($param);
    }

    public static function getAll(){
        return ChannelActivities::get();
    }
}