正在显示
1 个修改的文件
包含
53 行增加
和
1 行删除
| @@ -46,9 +46,61 @@ composer require lackoxygen/exception-push | @@ -46,9 +46,61 @@ composer require lackoxygen/exception-push | ||
| 46 | 46 | ||
| 47 | ``` | 47 | ``` |
| 48 | 48 | ||
| 49 | -# 使用方法 | 49 | +# 配置发布 |
| 50 | 50 | ||
| 51 | ```php | 51 | ```php |
| 52 | php artisan vendor:publish --provider=Lackoxygen\\ExceptionPush\\ExceptionPushProvider | 52 | php artisan vendor:publish --provider=Lackoxygen\\ExceptionPush\\ExceptionPushProvider |
| 53 | ``` | 53 | ``` |
| 54 | 54 | ||
| 55 | +# 同步 | ||
| 56 | + | ||
| 57 | +``` | ||
| 58 | +none | ||
| 59 | +``` | ||
| 60 | + | ||
| 61 | +# 异步 | ||
| 62 | + | ||
| 63 | +```php | ||
| 64 | +namespace App\Jobs; | ||
| 65 | + | ||
| 66 | +use Illuminate\Bus\Queueable; | ||
| 67 | +use Illuminate\Contracts\Queue\ShouldBeUnique; | ||
| 68 | +use Illuminate\Contracts\Queue\ShouldQueue; | ||
| 69 | +use Illuminate\Foundation\Bus\Dispatchable; | ||
| 70 | +use Illuminate\Queue\InteractsWithQueue; | ||
| 71 | +use Illuminate\Queue\SerializesModels; | ||
| 72 | +use Lackoxygen\ExceptionPush\Dispatcher; | ||
| 73 | + | ||
| 74 | +class Send implements ShouldQueue | ||
| 75 | +{ | ||
| 76 | + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
| 77 | + | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * Create a new job instance. | ||
| 81 | + * | ||
| 82 | + * @return void | ||
| 83 | + */ | ||
| 84 | + public function __construct($agents, $body) | ||
| 85 | + { | ||
| 86 | + $this->agents = $agents; | ||
| 87 | + | ||
| 88 | + $this->body = $body; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * Execute the job. | ||
| 93 | + * | ||
| 94 | + * @return void | ||
| 95 | + */ | ||
| 96 | + public function handle() | ||
| 97 | + { | ||
| 98 | + $dis = new Dispatcher(); | ||
| 99 | + $func = $dis->default(); | ||
| 100 | + | ||
| 101 | + $func($this->agents, $this->body); | ||
| 102 | + } | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +``` | ||
| 106 | + |
-
请 注册 或 登录 后发表评论