* Create the event listener. * * @return void*/publicfunction__construct() {//}/** * Handle the event. * * @param PodcastWasPurchased $event * @return void*/publicfunctionhandle(PodcastWasPurchased$event) {//Access the podcast using $event->podcast...} } 你的事件监听者也可以在构造函...
phpnamespaceApp\Listeners;useApp\Events\AsyncNotifyEvent;useIlluminate\Queue\InteractsWithQueue;useIlluminate\Contracts\Queue\ShouldQueue;classAsyncMassageNotifyEventListener{/** * Create the event listener. * * @return void */publicfunction__construct(){//}/** * Handle the event. * * @param Asyn...
namespace App\Listeners;useApp\Events\BlogView;useIlluminate\Queue\InteractsWithQueue;useIlluminate\Contracts\Queue\ShouldQueue;useIlluminate\Session\Store;classBlogViewListener {protected$session;/** * Create the event listener. * * @return void*/publicfunction__construct(Store$session) {$this->session...
* Create the event listener. * * @return void */publicfunction__construct(){//}/** * Handle the event. * * @param PostViewed $event * @return void */publicfunctionhandle(PostViewed $event){if($event->post->increment('views')){Redis::zincrby('popular_posts',1,$event->post->id);...
useIlluminate\Queue\InteractsWithQueue; useIlluminate\Contracts\Queue\ShouldQueue; classEmailPurchaseConfirmation { /** * Create the event listener. * *@returnvoid */ publicfunction__construct() { // } /** * Handle the event. * *@paramPodcastWasPurchased$event ...
*/protectedfunctionauthenticated(Request $request,$user){event(newUserLogin($user));} 1.2 创建listener 1.2.1 方式一:手动创建 代码语言:javascript 复制 php artisan make:listener EmailAdminUserLogin--event=UserLogin 1.2.2 方式二:推荐如下方式:自动生成事件和监听 ...
* Create the event listener. * *@returnvoid */ publicfunction__construct() { // } /** * Handle the event. * *@paramPodcastWasPurchased$event *@returnvoid */ publicfunctionhandle(PodcastWasPurchased$event) { //Access the podcast using $event->podcast... ...
* Create a new event instance. * * @param Podcast $podcast * @return void */publicfunction__construct(Podcast$podcast){$this->podcast=$podcast;}} 就如你所看到的,这个事件类并没有包含什么业务逻辑。它只是简单的包含了一个被购买的Podcast对象。SerializesModelstrait 被用来序列化 Eloquent 模型,如果...
phpnamespaceApp\Listeners;useCloudConvert\Models\WebhookEvent;useCloudConvert\Models\Job;useCloudConvert\Models\Task;useIlluminate\Support\Facades\Log;classCloudConvertEventListener {publicfunctiononJobFinished(WebhookEvent$event) {$job=$event->getJob();$job->getTag();// can be used to store an ID$...
When you register a listener to handle the event, the payload is easily accessible. You also have access to the original HTTP request. <?phpnamespaceApp\Listeners;useProtoneMedia\LaravelPaddle\Events\SubscriptionCreated;classCreateSubscriptionModel {publicfunctionhandle(SubscriptionCreated$event) {$status...