| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace FluentCart\App\Events\Subscription; |
| 5 |
|
| 6 |
use FluentCart\App\Events\EventDispatcher; |
| 7 |
use FluentCart\App\Listeners; |
| 8 |
use FluentCart\App\Models\Customer; |
| 9 |
use FluentCart\App\Models\Order; |
| 10 |
use FluentCart\App\Models\Subscription; |
| 11 |
|
| 12 |
|
| 13 |
class SubscriptionActivated extends EventDispatcher |
| 14 |
{ |
| 15 |
public string $hook = 'fluent_cart/subscription_activated'; |
| 16 |
protected array $listeners = [ |
| 17 |
|
| 18 |
]; |
| 19 |
|
| 20 |
/** |
| 21 |
* @var Subscription $subscription |
| 22 |
*/ |
| 23 |
public Subscription $subscription; |
| 24 |
|
| 25 |
/** |
| 26 |
* @var Customer|null $customer |
| 27 |
*/ |
| 28 |
public ?Customer $customer; |
| 29 |
|
| 30 |
/** |
| 31 |
* @var Order|null $order |
| 32 |
*/ |
| 33 |
public ?Order $order; |
| 34 |
|
| 35 |
public array $meta = []; |
| 36 |
|
| 37 |
public function __construct($subscription, $order = null, $customer = null, $meta = []) |
| 38 |
{ |
| 39 |
$this->subscription = $subscription; |
| 40 |
$this->order = $order; |
| 41 |
$this->customer = $customer; |
| 42 |
$this->meta = $meta; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
public function toArray(): array |
| 47 |
{ |
| 48 |
return [ |
| 49 |
'subscription' => $this->subscription, |
| 50 |
'order' => $this->order, |
| 51 |
'customer' => $this->customer ?? [], |
| 52 |
'meta' => $this->meta |
| 53 |
]; |
| 54 |
} |
| 55 |
|
| 56 |
public function getActivityEventModel() |
| 57 |
{ |
| 58 |
return $this->subscription; |
| 59 |
} |
| 60 |
|
| 61 |
} |