123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- namespace App\Distributor\Repositories;
- use App\Models\DistAdminDistributor as Model;
- use Dcat\Admin\Repositories\EloquentRepository;
- class DistAdminDistributor extends EloquentRepository
- {
-
- protected $eloquentClass = Model::class;
-
- public static function clearCache($timeOut = 2)
- {
- $domain = self::getDomain(0);
- $url = $domain . '/?__clear_cache=1';
- curlGet($url,$timeOut);
- }
-
- public static function getDomain($type=0)
- {
- $distId = getDistributorId();
- $model = new Model();
- return $model->getDomain($distId,$type);
- }
-
- public static function getInfo()
- {
- $id = getDistributorId();
- $row = Model::find($id);
- if ($row) {
- foreach ($row->getAttributes() as $key => $value) {
- $row->{$key} = $value ?? '';
- }
- }
- return $row;
- }
-
- public static function updateDomain($domainType,$customDomain)
- {
- $id = getDistributorId();
- $row = Model::find($id);
- $row->domain_type = $domainType;
- if ($domainType == 1) {
- $row->custom_domain = $customDomain;
- }
- $row->save();
- }
- public static function updateInfo($info)
- {
- $id = getDistributorId();
- $row = Model::find($id);
- $row->logo = $info['logo'];
- $row->site_name = $info['site_name'];
- $row->company_name = $info['company_name'];
- $row->company_address = $info['company_address'];
- $row->service_hotline = $info['service_hotline'];
- $row->dist_email = $info['dist_email'];
- $row->whats_app = $info['whats_app'];
- $row->facebook = $info['facebook'];
- $row->instagram = $info['instagram'];
- $row->youtube = $info['youtube'];
- $row->linkedin = $info['linkedin'];
- $row->tiktok = $info['tiktok'];
- $row->copy_right = $info['copy_right'];
- $row->seo_title = $info['seo_title'];
- $row->seo_keywords = $info['seo_keywords'];
- $row->seo_description = $info['seo_description'];
- $row->save();
- }
-
- public static function enableTheme($appearanceId)
- {
- $appearanceId = intval($appearanceId);
- $distId = getDistributorId();
- $distAppearance = new DistAppearance();
- $appearanceRow = $distAppearance->model()->find($appearanceId);
- if ($appearanceRow && $appearanceRow->enabled == 1) {
-
- $row = Model::find($distId);
- $row->appearance_id = $appearanceId;
- $row->save();
-
- DistAppearance::switchTheme($appearanceId, $distId);
- return true;
- }
- return false;
- }
- public static function all()
- {
- $result = Model::all();
- return $result;
- }
- public static function tags_all()
- {
- $result = Model::all();
-
- $tags = [];
- foreach ($result as $item) {
- $tags[$item->id] = $item->client_code;
- }
- return $tags;
- }
- public static function getCompanyNamesByIds(array $ids)
- {
- return Model::whereIn('id', $ids)->pluck('company_name')->toArray();
- }
- }
|