DistAdminDistributor.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 getDomain()
  17. {
  18. $distId = getDistributorId();
  19. $model = new Model();
  20. return $model->getDomain($distId);
  21. }
  22. /*
  23. * 得到分销商信息
  24. */
  25. public static function getInfo()
  26. {
  27. $id = getDistributorId();
  28. $row = Model::find($id);
  29. return $row;
  30. }
  31. /*
  32. * 修改域名名称
  33. */
  34. public static function updateDomain($domainType,$customDomain)
  35. {
  36. $id = getDistributorId();
  37. $row = Model::find($id);
  38. $row->domain_type = $domainType;
  39. if ($domainType == 1) {
  40. $row->custom_domain = $customDomain;
  41. }
  42. $row->save();
  43. }
  44. public static function updateInfo($info)
  45. {
  46. $id = getDistributorId();
  47. $row = Model::find($id);
  48. $row->logo = $info['logo'];
  49. $row->site_name = $info['site_name'];
  50. $row->company_name = $info['company_name'];
  51. $row->company_address = $info['company_address'];
  52. $row->contact_number = $info['contact_number'];
  53. $row->service_hotline = $info['service_hotline'];
  54. $row->whats_app = $info['whats_app'];
  55. $row->facebook = $info['facebook'];
  56. $row->instagram = $info['instagram'];
  57. $row->youtube = $info['youtube'];
  58. $row->linkedin = $info['linkedin'];
  59. $row->tiktok = $info['tiktok'];
  60. $row->seo_title = $info['seo_title'];//seo_title
  61. $row->seo_keywords = $info['seo_keywords'];//seo_keywords
  62. $row->seo_description = $info['seo_description'];//seo_description
  63. $row->save();
  64. }
  65. /*
  66. * 分销商切换主题
  67. */
  68. public static function enableTheme($appearanceId)
  69. {
  70. $appearanceId = intval($appearanceId);
  71. $distId = getDistributorId();
  72. $distAppearance = new DistAppearance();
  73. $appearanceRow = $distAppearance->model()->find($appearanceId);
  74. if ($appearanceRow && $appearanceRow->enabled == 1) {
  75. //修改分销商主题
  76. $row = Model::find($distId);
  77. $row->appearance_id = $appearanceId;
  78. $row->save();
  79. //切换主题
  80. DistAppearance::switchTheme($appearanceId, $distId);
  81. return true;
  82. }
  83. return false;
  84. }
  85. }