Verbs

Reset Plan Report State

1<?php ...
2 
3namespace Thunk\Verbs\Examples\Subscriptions\Events;
4 
5use Thunk\Verbs\Event;
6use Thunk\Verbs\Examples\Subscriptions\States\PlanReportState;
7use Thunk\Verbs\Support\StateCollection;
8 
9class ResetPlanReportState extends Event
10{
11 public int $plan_id;
12 
13 public function states(): StateCollection
14 {
15 return new StateCollection([
16 PlanReportState::class => PlanReportState::load($this->plan_id),
17 ]);
18 }
19 
20 public function apply(PlanReportState $state)
21 {
22 $state->subscribes_since_last_report = 0;
23 $state->unsubscribes_since_last_report = 0;
24 $state->last_reported_at = now();
25 }
26}