| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Events\License; |
| 4 |
|
| 5 |
use FluentCart\App\Events\EventDispatcher; |
| 6 |
use FluentCart\App\Models\Order; |
| 7 |
use FluentCartPro\App\Modules\Licensing\Models\License; |
| 8 |
|
| 9 |
class LicenseRenewed extends EventDispatcher |
| 10 |
{ |
| 11 |
|
| 12 |
public string $hook = 'fluent_cart/license_renewed'; |
| 13 |
protected array $listeners = []; |
| 14 |
|
| 15 |
/** |
| 16 |
* @var License |
| 17 |
*/ |
| 18 |
public License $license; |
| 19 |
|
| 20 |
/** |
| 21 |
* @var Order |
| 22 |
*/ |
| 23 |
public Order $order; |
| 24 |
|
| 25 |
public function __construct(Order $order, License $license) |
| 26 |
{ |
| 27 |
$this->order = $order; |
| 28 |
$this->order->load('customer', 'subscriptions'); |
| 29 |
$this->license = $license; |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
public function toArray(): array |
| 34 |
{ |
| 35 |
return [ |
| 36 |
'order' => $this->order, |
| 37 |
'license' => $this->license, |
| 38 |
'customer' => $this->order->customer ?? [], |
| 39 |
'subscriptions' => $this->order->subscriptions ?? [], |
| 40 |
]; |
| 41 |
} |
| 42 |
|
| 43 |
public function getActivityEventModel() |
| 44 |
{ |
| 45 |
return $this->license; |
| 46 |
} |
| 47 |
|
| 48 |
public function shouldCreateActivity(): bool |
| 49 |
{ |
| 50 |
return true; |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
} |