AppCreatedEvent.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Module\OpenAPI\Events;
  3. use App\Module\OpenAPI\Models\OpenApiApp;
  4. use Illuminate\Foundation\Events\Dispatchable;
  5. use Illuminate\Queue\SerializesModels;
  6. /**
  7. * 应用创建事件
  8. */
  9. class AppCreatedEvent
  10. {
  11. use Dispatchable, SerializesModels;
  12. /**
  13. * @var OpenApiApp
  14. */
  15. public OpenApiApp $app;
  16. /**
  17. * 创建新的事件实例
  18. *
  19. * @param OpenApiApp $app
  20. */
  21. public function __construct(OpenApiApp $app)
  22. {
  23. $this->app = $app;
  24. }
  25. /**
  26. * 获取应用信息
  27. *
  28. * @return OpenApiApp
  29. */
  30. public function getApp(): OpenApiApp
  31. {
  32. return $this->app;
  33. }
  34. /**
  35. * 获取应用ID
  36. *
  37. * @return string
  38. */
  39. public function getAppId(): string
  40. {
  41. return $this->app->app_id;
  42. }
  43. /**
  44. * 获取应用名称
  45. *
  46. * @return string
  47. */
  48. public function getAppName(): string
  49. {
  50. return $this->app->name;
  51. }
  52. /**
  53. * 获取创建用户ID
  54. *
  55. * @return int
  56. */
  57. public function getUserId(): int
  58. {
  59. return $this->app->user_id;
  60. }
  61. /**
  62. * 获取创建用户名称
  63. *
  64. * @return string
  65. */
  66. public function getUserName(): string
  67. {
  68. return $this->app->user_name;
  69. }
  70. }