GenerateKeyRow.php 874 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Mead
  5. * Date: 2017/11/16
  6. * Time: 15:48
  7. */
  8. namespace App\Admin\Extensions;
  9. use Encore\Admin\Admin;
  10. class GenerateKeyRow
  11. {
  12. protected $id;
  13. public function __construct($id)
  14. {
  15. $this->id = $id;
  16. }
  17. protected function script()
  18. {
  19. return <<<SCRIPT
  20. $('.grid-generate-key-row').on('click', function () {
  21. // Your code.
  22. console.log($(this).data('id'));
  23. var id = $(this).data('id');
  24. $.get('/admin/key',{id:id},function(data){
  25. console.log(data);
  26. });
  27. });
  28. SCRIPT;
  29. }
  30. protected function render()
  31. {
  32. Admin::script($this->script());
  33. return "<a title='生成key' class='btn btn-xs btn-success fa fa-sitemap grid-generate-key-row' data-id='{$this->id}'></a>";
  34. }
  35. public function __toString()
  36. {
  37. return $this->render();
  38. }
  39. }