<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### 1: 生成事件和監聽器 可以使用`make:event`以及`make:listener`用于生成單個事件和監聽器的 Artisan 命令 #### 事件 ``` php artisan make:event SysNotifyEvent ``` #### 監聽器 ``` php artisan make:listener SysNotifyListener --event=SysNotifyEvent ``` ### 2: 手動注冊事件 通常,事件應該通過 EventServiceProvider $listen 數組注冊;但是,你也可以在 EventServiceProvider 的 boot 方法中手動注冊基于類或閉包的事件監聽器: ~~~ public function boot(): void { Event::listen( SysNotifyEvent::class, [SysNotifyListener::class, 'handle'] ); } ~~~ 或者 ~~~ protected $listen = [ SysNotifyEvent::class => [ SysNotifyListener::class ], ]; ~~~ ### 3:定義事件 ~~~ namespace App\Events; class SysNotifyEvent { public function __construct(public $to_user_id = null, public $content = '') { } } ~~~ ### 4:定義監聽器 ~~~ <?php namespace App\Listeners; use App\Events\SysNotifyEvent; use App\Models\UserJobNotifaction; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; class SysNotifyListener { public function handle(SysNotifyEvent $event): void { UserJobNotifaction::create([ 'user_id' => UserJobNotifaction::SYS_NOTIFY_TYPE_NUMBER, 'to_user_id' => $event->to_user_id, 'content' => $event->content, 'type' => 'text', 'input_time' => getSystime() ]); } } ~~~ 如果使用隊列繼承ShouldQueue類 ~~~ class SysNotifyListener implements ShouldQueue ~~~ > 如果你的監聽器要執行一個緩慢的任務,如發送電子郵件或進行 HTTP 請求,那么隊列化監聽器就很有用了。在使用隊列監聽器之前,請確保 配置你的隊列 并在你的服務器或本地開發環境中啟動一個隊列 worker。 ### 5:使用方法 ~~~ SysNotifyEvent::dispatch($user_id, '?? ??? ????? ????????'); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看