DistAdminDistributor.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Distributor\Repositories;
  3. use App\Models\DistAdminDistributor as Model;
  4. use Dcat\Admin\Repositories\EloquentRepository;
  5. class DistAdminDistributor extends EloquentRepository
  6. {
  7. /**
  8. * Model.
  9. *
  10. * @var string
  11. */
  12. protected $eloquentClass = Model::class;
  13. /*
  14. * 得到分销商信息
  15. */
  16. public static function getInfo()
  17. {
  18. $id = getDistributorId();
  19. $row = Model::find($id);
  20. return $row;
  21. }
  22. /*
  23. * 修改域名名称
  24. */
  25. public static function updateDomain($domainType,$customDomain)
  26. {
  27. $id = getDistributorId();
  28. $row = Model::find($id);
  29. $row->domain_type = $domainType;
  30. if ($domainType == 1) {
  31. $row->custom_domain = $customDomain;
  32. }
  33. $row->save();
  34. }
  35. public static function updateInfo($info)
  36. {
  37. $id = getDistributorId();
  38. $row = Model::find($id);
  39. $row->logo = $info['logo'];
  40. $row->site_name = $info['site_name'];
  41. $row->company_name = $info['company_name'];
  42. $row->company_address = $info['company_address'];
  43. $row->contact_number = $info['contact_number'];
  44. $row->service_hotline = $info['service_hotline'];
  45. $row->whats_app = $info['whats_app'];
  46. $row->seo_title = $info['seo_title'];//seo_title
  47. $row->seo_keywords = $info['seo_keywords'];//seo_keywords
  48. $row->seo_description = $info['seo_description'];//seo_description
  49. $row->save();
  50. }
  51. /*
  52. * 分销商切换主题
  53. */
  54. public static function enableTheme($appearanceId)
  55. {
  56. $appearanceId = intval($appearanceId);
  57. $distId = getDistributorId();
  58. $distAppearance = new DistAppearance();
  59. $appearanceRow = $distAppearance->model()->find($appearanceId);
  60. if ($appearanceRow && $appearanceRow->enabled == 1) {
  61. //修改分销商主题
  62. $row = Model::find($distId);
  63. $row->appearance_id = $appearanceId;
  64. $row->save();
  65. //切换主题
  66. DistAppearance::switchTheme($appearanceId, $distId);
  67. return true;
  68. }
  69. return false;
  70. }
  71. }