FrontendVersionController.php 917 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\backend\controllers;
  3. use app\common\components\BaseController;
  4. class FrontendVersionController extends BaseController
  5. {
  6. public function index()
  7. {
  8. return view('frontend.version',[])->render();
  9. }
  10. public function getVersion()
  11. {
  12. $frontend_version = config('front-version');
  13. return $this->successJson('ok', ['version' => $frontend_version]);
  14. }
  15. public function change()
  16. {
  17. $version = request()->input('version');
  18. if (empty($version)) {
  19. return $this->errorJson('请填写版本号');
  20. }
  21. $str = file_get_contents(base_path('config/') . 'front-version.php');
  22. $str = preg_replace('/"[\d\.]+"/', '"' . $version . '"', $str);
  23. file_put_contents(base_path('config/') . 'front-version.php', $str);
  24. \Artisan::call('config:cache');
  25. return $this->successJson('ok');
  26. }
  27. }