SettingController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Http\Controllers\V1;
  3. use App\Models\Banner;
  4. use App\Models\HomeColumn;
  5. use App\Models\NavBar;
  6. use App\Models\RechargeCombo;
  7. use App\Models\Setting;
  8. use App\Models\Tabbar;
  9. use App\Models\VipCombo;
  10. class SettingController extends Controller
  11. {
  12. /**
  13. * 底部导航
  14. */
  15. public function tabBar()
  16. {
  17. $all = Tabbar::select(['name as text','icon','selected_icon','type'])
  18. ->where('status',1)
  19. ->orderBy('sort')
  20. ->get();
  21. return $this->success($all);
  22. }
  23. /**
  24. * 首页顶部分类
  25. */
  26. public function navBar()
  27. {
  28. $all = NavBar::select(['name','icon','type'])
  29. ->where('status',1)
  30. ->orderBy('sort')
  31. ->get();
  32. return $this->success($all);
  33. }
  34. /**
  35. * 首页顶部分类
  36. */
  37. public function banner()
  38. {
  39. $all = Banner::select(['name as title','image','episode_id'])
  40. ->where('status',1)
  41. ->orderBy('sort')
  42. ->get();
  43. return $this->success($all);
  44. }
  45. public function homeColumn()
  46. {
  47. $all = HomeColumn::select(['name','type'])
  48. ->where('status',1)
  49. ->orderBy('sort')
  50. ->get();
  51. return $this->success($all);
  52. }
  53. public function rechargeCombo()
  54. {
  55. $lists = RechargeCombo::where('status', 1)->get()->toArray();
  56. $vipCombo = VipCombo::select(['id','name','price','valid_day','desc'])
  57. ->where('status', 1)
  58. ->orderByDesc('valid_day')
  59. ->first()->toArray();
  60. $vipCombo['vip_combo'] = 1;
  61. $offset = collect($lists)->count() > 6 ? 5 : collect($lists)->count();
  62. array_splice($lists,$offset,1, [$vipCombo]);
  63. return $this->success($lists);
  64. }
  65. public function config()
  66. {
  67. $config = Setting::first();
  68. return $this->success($config);
  69. }
  70. }