<?php

namespace App\Modules\OfficialAccount\Models;

use Illuminate\Database\Eloquent\Model;

class ForbiddenOfficialAccountRecord extends Model
{
    protected $tables = 'forbidden_official_account_records';

    protected $fillable = ['distribution_channel_id','appid','nickname','company_id','company_name','forbbidden_time','unforbidden_time','business_name','date','created_at','updated_at'];


    static function save_or_update($data)
    {
    	$distribution_channel_id = isset($data['distribution_channel_id'])?$data['distribution_channel_id']:'';
    	$appid = isset($data['appid'])?$data['appid']:'';
    	$nickname = isset($data['nickname'])?$data['nickname']:'';
    	$company_id = isset($data['company_id'])?$data['company_id']:'';
    	$company_name = isset($data['company_name'])?$data['company_name']:'';
    	$business_name = isset($data['business_name'])?$data['business_name']:'';
    	$forbbidden_time = isset($data['forbbidden_time'])?$data['forbbidden_time']:'';
    	$unforbidden_time = isset($data['unforbidden_time'])?$data['unforbidden_time']:'';
    	$date = isset($data['date'])?$data['date']:'';
    	$created_at = isset($data['created_at'])?$data['created_at']:'';
    	$updated_at = isset($data['updated_at'])?$data['updated_at']:'';
    	
    	$base_data = compact('distribution_channel_id','appid','date');
    	$extra_data = compact('nickname', 'company_id', 'company_name', 'business_name', 'forbbidden_time', 'unforbidden_time', 'created_at', 'updated_at');
    	return self::updateOrCreate($base_data, $extra_data);
    
    }

}


