<?php

namespace App\Admin\Repositories;

use App\Models\DistAppearanceVariable as Model;
use Dcat\Admin\Form;
use Dcat\Admin\Repositories\EloquentRepository;
use App\Models\SiteAppearanceVariable;
use Illuminate\Support\Carbon;

class DistAppearanceVariable extends EloquentRepository
{
    /**
     * Model.
     *
     * @var string
     */
    protected $eloquentClass = Model::class;


    public static function getVariableRow($distId,$appearanceId,$templateId)
    {
        $model = new Model();
        $variable = $model->where('dist_id',$distId)->where('appearance_id',$appearanceId)->whereIn('template_id',[0,$templateId])->get();
        if($variable){
            return $variable;
        }else{
            return '';
        }
    }

    /*
     * 把原始变量复制给分销商
     */
    public static function copyAppearanceVariable($appearanceId, $distId){
        Model::copyAppearanceVariable($appearanceId, $distId);
    }


    /*
     * 删除分销商主题变量
     */
    public static function deleteVariable($appearanceId,$distId)
    {
        return Model::deleteVariable($appearanceId, $distId);
    }


    /*
     * 同步变量到正式表
     */
    public static function syncAppearanceVariables($appearanceId,$distId) {
      $model = new Model();
      return $model->syncAppearanceVariables($appearanceId,$distId);
    }

}
