NewMediaCountController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\NewMediaAccount;
  4. use App\Models\NewMediaCount;
  5. use Encore\Admin\Controllers\AdminController;
  6. use Encore\Admin\Form;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Show;
  9. class NewMediaCountController extends AdminController
  10. {
  11. /**
  12. * Title for current resource.
  13. *
  14. * @var string
  15. */
  16. protected $title = '新媒体账号播放统计';
  17. /**
  18. * Make a grid builder.
  19. *
  20. * @return Grid
  21. */
  22. protected function grid()
  23. {
  24. $grid = new Grid(new NewMediaCount());
  25. $grid->column('id', __('Id'));
  26. $grid->column('day', __('月份'));
  27. $grid->column('num', __('总计播放量'));
  28. $grid->column('created_at', __('导入时间'));
  29. return $grid;
  30. }
  31. /**
  32. * Make a show builder.
  33. *
  34. * @param mixed $id
  35. * @return Show
  36. */
  37. protected function detail($id)
  38. {
  39. $show = new Show(NewMediaAccount::findOrFail($id));
  40. $show->field('id', __('Id'));
  41. $show->field('account_name', __('账号名称'));
  42. $show->field('account_platform', __('账号平台'))->using(NewMediaAccount::PLATFORM_MAP);
  43. $show->field('fans_num', __('粉丝数'));
  44. $show->field('created_at', __('Created at'));
  45. $show->field('updated_at', __('Updated at'));
  46. return $show;
  47. }
  48. /**
  49. * Make a form builder.
  50. *
  51. * @return Form
  52. */
  53. protected function form()
  54. {
  55. $form = new Form(new NewMediaCount());
  56. $form->select('year', __('年份'))->options(array_combine(range(2024,date('Y')), range(2024,date('Y'))));
  57. $form->select('month','月份')->options(array_combine(range(1,12), range(1,12)));
  58. $form->file('count_file','统计文件')->rules('mimes:xlsx');
  59. $form->keyValue('count_data','统计数据');
  60. return $form;
  61. }
  62. }