SysVersionController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\SysVersion;
  4. use Encore\Admin\Controllers\AdminController;
  5. use Encore\Admin\Form;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Show;
  8. class SysVersionController extends AdminController
  9. {
  10. /**
  11. * Title for current resource.
  12. *
  13. * @var string
  14. */
  15. protected $title = 'APP版本';
  16. /**
  17. * Make a grid builder.
  18. *
  19. * @return Grid
  20. */
  21. protected function grid()
  22. {
  23. $grid = new Grid(new SysVersion());
  24. $grid->column('id', __('Id'));
  25. $grid->column('type', __('类型'))->display(function($type){
  26. return SysVersion::$typeMap[$type];
  27. });
  28. $grid->column('version_number', __('版本号'));
  29. $grid->column('description', __('版本更新说明'));
  30. $grid->column('web_url', __('版本下载网址'));
  31. $grid->column('aos_url', __('安卓下载地址'));
  32. $grid->column('ios_url', __('苹果下载地址'));
  33. $grid->column('is_must', __('是否强制更新'))->display(function($isMust){
  34. return SysVersion::$isMustMap[$isMust];
  35. });
  36. return $grid;
  37. }
  38. /**
  39. * Make a show builder.
  40. *
  41. * @param mixed $id
  42. * @return Show
  43. */
  44. protected function detail($id)
  45. {
  46. $show = new Show(SysVersion::findOrFail($id));
  47. $show->field('id', __('Id'));
  48. $show->field('type', __('Type'));
  49. $show->field('version_number', __('Version number'));
  50. $show->field('description', __('Description'));
  51. $show->field('web_url', __('Web url'));
  52. $show->field('aos_url', __('Aos url'));
  53. $show->field('ios_url', __('Ios url'));
  54. $show->field('is_must', __('Is must'));
  55. $show->field('created_at', __('Created at'));
  56. $show->field('updated_at', __('Updated at'));
  57. $show->field('deleted_at', __('Deleted at'));
  58. return $show;
  59. }
  60. /**
  61. * Make a form builder.
  62. *
  63. * @return Form
  64. */
  65. protected function form()
  66. {
  67. $form = new Form(new SysVersion());
  68. $form->select('type', __('类型'))->options(SysVersion::$typeMap);
  69. $form->text('version_number', __('版本号'));
  70. $form->text('description', __('版本更新说明'));
  71. $form->file('web_url', __('版本下载网址'));
  72. $form->text('aos_url', __('安卓下载地址'));
  73. $form->text('ios_url', __('苹果下载地址'));
  74. $form->switch('is_must', __('是否强制更新'));
  75. return $form;
  76. }
  77. }