123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App\Admin\Repositories;
- use App\Models\DistAppearance as Model;
- use Carbon\Carbon;
- use Dcat\Admin\Repositories\EloquentRepository;
- class DistAppearance extends EloquentRepository
- {
- /**
- * Model.
- *
- * @var string
- */
- protected $eloquentClass = Model::class;
- /*
- * 获取一个标签
- */
- public static function getOneById($id)
- {
- return Model::where('id', $id)->first();
- }
- public static function selectOptions($valueShowId = false)
- {
- $data = Model::where('enabled', 1)->get();
- $options = [];
- foreach ($data as $item) {
- if ($valueShowId) {
- $options[$item->id] = $item->id.' - '.$item->title;
- } else {
- $options[$item->id] = $item->title;
- }
- }
- return $options;
- }
- /*
- * 设置状态为已导入
- */
- public static function setStatusToImported($id)
- {
- $row = Model::where('id', $id)->first();
- if ($row) {
- $row->updated_at = Carbon::now();
- $row->imported = 1;
- $row->save();
- }
- return true;
- }
- /*
- * 切换主题操作,生成销应商主题模版与变量
- * (如果原本就有模板与变量,不会重复生成)
- */
- public static function switchTheme($appearanceId,$distId) {
- DistAppearanceTemplate::copyTemplateToDist($appearanceId, $distId);
- DistAppearanceVariable::copyAppearanceVariable($appearanceId, $distId);
- return true;
- }
- /*
- * 初始化分销商模版与变量
- */
- public static function initTheme($appearanceId,$distId)
- {
- //请空模版与变量
- DistAppearanceTemplate::deleteTemplates($appearanceId,$distId);
- DistAppearanceVariable::deleteVariable($appearanceId, $distId);
- //重新生成模版与变量
- self::switchTheme($appearanceId, $distId);
- }
- }
|