链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.4 KiB

  1. <?php
  2. namespace App\Admin\Actions\Tree;
  3. use Dcat\Admin\Actions\Response;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Traits\HasPermissions;
  6. use Dcat\Admin\Tree\AbstractTool;
  7. use Illuminate\Contracts\Auth\Authenticatable;
  8. use Illuminate\Database\Eloquent\Model;
  9. use Illuminate\Http\Request;
  10. use App\Models\v3\Category as CategoryModel;
  11. class CategoryTie extends AbstractTool
  12. {
  13. /**
  14. * @return string
  15. */
  16. protected $title = '绑定分类到首页';
  17. /**
  18. * Handle the action request.
  19. *
  20. * @param Request $request
  21. *
  22. * @return Response
  23. */
  24. public function handle(Request $request)
  25. {
  26. return $this->response()
  27. ->success('Processed successfully.')
  28. ->redirect('/category');
  29. }
  30. /**
  31. * @return string|void
  32. */
  33. public function href()
  34. {
  35. // return admin_url('category/tie');
  36. }
  37. /**
  38. * @return string|array|void
  39. */
  40. public function confirm()
  41. {
  42. // return ['Confirm?', 'contents'];
  43. }
  44. /**
  45. * 添加JS
  46. *
  47. * @return string
  48. */
  49. protected function script()
  50. {
  51. return <<<JS
  52. $('.category-tie-row').on('click', function () {
  53. // Your code.
  54. window.location.href ='/admin/category/tie';
  55. });
  56. JS;
  57. }
  58. /**
  59. * @param Model|Authenticatable|HasPermissions|null $user
  60. *
  61. * @return bool
  62. */
  63. protected function authorize($user): bool
  64. {
  65. return true;
  66. }
  67. }