SmmUserAccountController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Distributor\Controllers;
  3. use App\Distributor\Actions\SmmAddAccount;
  4. use App\Distributor\Repositories\SmmUserAccount;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. use Dcat\Admin\Layout\Content;
  10. use Dcat\Admin\Admin;
  11. class SmmUserAccountController extends AdminController
  12. {
  13. /**
  14. * page index
  15. */
  16. public function index(Content $content)
  17. {
  18. return $content
  19. ->header('帐号管理')
  20. ->description('全部')
  21. ->body($this->grid());
  22. }
  23. /**
  24. * Make a grid builder.
  25. *
  26. * @return Grid
  27. */
  28. protected function grid()
  29. {
  30. return Grid::make(new SmmUserAccount(), function (Grid $grid) {
  31. $grid->column('id')->sortable();
  32. $grid->column('user_name');
  33. $grid->column('access_token');
  34. $grid->column('media_name');
  35. $grid->column('created_at');
  36. $grid->column('updated_at')->sortable();
  37. $grid->filter(function (Grid\Filter $filter) {
  38. $filter->panel();
  39. $filter->expand();
  40. $filter->like('user_name')->width(2);
  41. });
  42. //授权按钮
  43. // 传入数组
  44. $grid->rightTools([
  45. new SmmAddAccount(),
  46. ]);
  47. $grid->disableCreateButton();
  48. $grid->disableEditButton();
  49. $grid->model()->where('dist_id', getDistributorId())->orderBy('media_name', 'asc')->orderBy('id', 'desc');
  50. });
  51. }
  52. }