From f864a83fbaaf42c83187e373b73ed849fa2938e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 17 Oct 2024 17:45:50 +0200 Subject: [PATCH 01/13] payment was updated --- app/Events/Payment/PaymentWasUpdated.php | 33 ++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/app/Events/Payment/PaymentWasUpdated.php b/app/Events/Payment/PaymentWasUpdated.php index e414cfddf0..114c1357d6 100644 --- a/app/Events/Payment/PaymentWasUpdated.php +++ b/app/Events/Payment/PaymentWasUpdated.php @@ -13,14 +13,20 @@ namespace App\Events\Payment; use App\Models\Company; use App\Models\Payment; +use App\Transformers\ArraySerializer; +use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Queue\SerializesModels; +use League\Fractal\Manager; +use League\Fractal\Resource\Item; /** * Class PaymentWasUpdated. */ -class PaymentWasUpdated +class PaymentWasUpdated implements ShouldBroadcast { - use SerializesModels; + use SerializesModels, InteractsWithSockets; /** * @var Payment @@ -43,5 +49,28 @@ class PaymentWasUpdated $this->payment = $payment; $this->company = $company; $this->event_vars = $event_vars; + + $this->dontBroadcastToCurrentUser(); + } + + public function broadcastOn(): array + { + return [ + new PrivateChannel("company-{$this->company->company_key}"), + ]; + } + + public function broadcastWith(): array + { + $manager = new Manager(); + $manager->setSerializer(new ArraySerializer()); + $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->payment)); + + $transformer = new $class(); + + $resource = new Item($this->payment, $transformer, $this->payment->getEntityType()); + $data = $manager->createData($resource)->toArray(); + + return [...$data, 'x-socket-id' => $this->socket]; } } From bcf46e66ff878cd6966447621cd486d0af240feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 17 Oct 2024 17:45:57 +0200 Subject: [PATCH 02/13] update translations --- lang/en/texts.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lang/en/texts.php b/lang/en/texts.php index 6089824a10..73c5bcae98 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5360,7 +5360,8 @@ $lang = array( 'vat_not_registered' => 'Seller not VAT registered', 'small_company_info' => 'No disclosure of sales tax in accordance with ยง 19 UStG', 'log_duration_words' => 'Time log duration in words', - 'log_duration' => 'Time log duration' + 'log_duration' => 'Time log duration', + 'payment_status_changed' => 'Please note that the status of your payment has been updated. We recommend refreshing the page to view the most current version.', ); return $lang; From b40cdff4510b25ce5df6958946cdc895c1113afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 17 Oct 2024 17:59:16 +0200 Subject: [PATCH 03/13] support for credit was created --- app/Events/Credit/CreditWasCreated.php | 36 +++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/app/Events/Credit/CreditWasCreated.php b/app/Events/Credit/CreditWasCreated.php index 3139616730..93a7fbeed1 100644 --- a/app/Events/Credit/CreditWasCreated.php +++ b/app/Events/Credit/CreditWasCreated.php @@ -14,10 +14,15 @@ namespace App\Events\Credit; use App\Models\Company; use App\Models\Credit; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use League\Fractal\Manager; +use App\Transformers\ArraySerializer; +use League\Fractal\Resource\Item; -class CreditWasCreated +class CreditWasCreated implements ShouldBroadcast { use Dispatchable; use InteractsWithSockets; @@ -41,5 +46,34 @@ class CreditWasCreated $this->credit = $credit; $this->company = $company; $this->event_vars = $event_vars; + + $this->dontBroadcastToCurrentUser(); + } + + /** + * @inheritDoc + */ + public function broadcastOn() + { + return [ + new PrivateChannel("company-{$this->company->company_key}"), + ]; + } + + /** + * @inheritDoc + */ + public function broadcastWith(): array + { + $manager = new Manager(); + $manager->setSerializer(new ArraySerializer()); + $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->credit)); + + $transformer = new $class(); + + $resource = new Item($this->credit, $transformer, $this->credit->getEntityType()); + $data = $manager->createData($resource)->toArray(); + + return [...$data, 'x-socket-id' => $this->socket]; } } From caf36a15949b92d2cba43e24ddc1e3067f3f758e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 17 Oct 2024 17:59:21 +0200 Subject: [PATCH 04/13] support for credit was updated --- app/Events/Credit/CreditWasUpdated.php | 36 +++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/app/Events/Credit/CreditWasUpdated.php b/app/Events/Credit/CreditWasUpdated.php index 1cf266f3f2..977220b1d2 100644 --- a/app/Events/Credit/CreditWasUpdated.php +++ b/app/Events/Credit/CreditWasUpdated.php @@ -14,10 +14,15 @@ namespace App\Events\Credit; use App\Models\Company; use App\Models\Credit; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use League\Fractal\Manager; +use App\Transformers\ArraySerializer; +use League\Fractal\Resource\Item; -class CreditWasUpdated +class CreditWasUpdated implements ShouldBroadcast { use Dispatchable; use InteractsWithSockets; @@ -41,5 +46,34 @@ class CreditWasUpdated $this->credit = $credit; $this->company = $company; $this->event_vars = $event_vars; + + $this->dontBroadcastToCurrentUser(); + } + + /** + * @inheritDoc + */ + public function broadcastOn() + { + return [ + new PrivateChannel("company-{$this->company->company_key}"), + ]; + } + + /** + * @inheritDoc + */ + public function broadcastWith(): array + { + $manager = new Manager(); + $manager->setSerializer(new ArraySerializer()); + $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->credit)); + + $transformer = new $class(); + + $resource = new Item($this->credit, $transformer, $this->credit->getEntityType()); + $data = $manager->createData($resource)->toArray(); + + return [...$data, 'x-socket-id' => $this->socket]; } } From 7055244b8a9047426e8d204a39f78de21389b1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 17 Oct 2024 17:59:25 +0200 Subject: [PATCH 05/13] update translations --- lang/en/texts.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lang/en/texts.php b/lang/en/texts.php index 73c5bcae98..39576276d0 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5362,6 +5362,7 @@ $lang = array( 'log_duration_words' => 'Time log duration in words', 'log_duration' => 'Time log duration', 'payment_status_changed' => 'Please note that the status of your payment has been updated. We recommend refreshing the page to view the most current version.', + 'credit_status_changed' => 'Please note that the status of your credit has been updated. We recommend refreshing the page to view the most current version.', ); return $lang; From e1ae0c940ebb0c8ac24f3e18bf1bd373a5561ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 17 Oct 2024 18:54:04 +0200 Subject: [PATCH 06/13] support for invoice was viewed --- app/Events/Invoice/InvoiceWasViewed.php | 35 +++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/app/Events/Invoice/InvoiceWasViewed.php b/app/Events/Invoice/InvoiceWasViewed.php index 5aaf0dffdf..378628bf17 100644 --- a/app/Events/Invoice/InvoiceWasViewed.php +++ b/app/Events/Invoice/InvoiceWasViewed.php @@ -13,15 +13,21 @@ namespace App\Events\Invoice; use App\Models\Company; use App\Models\InvoiceInvitation; +use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Queue\SerializesModels; +use League\Fractal\Manager; +use App\Transformers\ArraySerializer; +use League\Fractal\Resource\Item; /** * Class InvoiceWasViewed. */ -class InvoiceWasViewed +class InvoiceWasViewed implements ShouldBroadcast { use SerializesModels; - + use InteractsWithSockets; /** * Create a new event instance. @@ -32,5 +38,30 @@ class InvoiceWasViewed */ public function __construct(public InvoiceInvitation $invitation, public Company $company, public array $event_vars) { + // + } + + public function broadcastOn(): array + { + return [ + new PrivateChannel("company-{$this->company->company_key}"), + ]; + } + + public function broadcastWith(): array + { + $manager = new Manager(); + $manager->setSerializer(new ArraySerializer()); + $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->invitation->invoice)); + + $transformer = new $class(); + + $resource = new Item($this->invitation->invoice, $transformer, $this->invitation->invoice->getEntityType()); + + $manager->parseIncludes('client'); + + $data = $manager->createData($resource)->toArray(); + + return $data; } } From 95e6ed49de689b37d9beaaab0981e0494bd5eea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 18 Oct 2024 16:54:16 +0200 Subject: [PATCH 07/13] update translations --- lang/en/texts.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lang/en/texts.php b/lang/en/texts.php index 39576276d0..f431a9532e 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5363,6 +5363,8 @@ $lang = array( 'log_duration' => 'Time log duration', 'payment_status_changed' => 'Please note that the status of your payment has been updated. We recommend refreshing the page to view the most current version.', 'credit_status_changed' => 'Please note that the status of your credit has been updated. We recommend refreshing the page to view the most current version.', + 'credit_updated' => 'Credit Updated', + 'payment_updated' => 'Payment Updated', ); return $lang; From e1da6c1ead6f3129e137462dd2c86d83b9b9ffd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 18 Oct 2024 18:32:42 +0200 Subject: [PATCH 08/13] default resource broadcast --- ...dcast.php => DefaultResourceBroadcast.php} | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) rename app/Utils/Traits/Invoice/Broadcasting/{DefaultInvoiceBroadcast.php => DefaultResourceBroadcast.php} (58%) diff --git a/app/Utils/Traits/Invoice/Broadcasting/DefaultInvoiceBroadcast.php b/app/Utils/Traits/Invoice/Broadcasting/DefaultResourceBroadcast.php similarity index 58% rename from app/Utils/Traits/Invoice/Broadcasting/DefaultInvoiceBroadcast.php rename to app/Utils/Traits/Invoice/Broadcasting/DefaultResourceBroadcast.php index ce33363777..50c88371fa 100644 --- a/app/Utils/Traits/Invoice/Broadcasting/DefaultInvoiceBroadcast.php +++ b/app/Utils/Traits/Invoice/Broadcasting/DefaultResourceBroadcast.php @@ -12,12 +12,13 @@ namespace App\Utils\Traits\Invoice\Broadcasting; +use App\Models\BaseModel; use App\Transformers\ArraySerializer; use Illuminate\Broadcasting\PrivateChannel; use League\Fractal\Manager; use League\Fractal\Resource\Item; -trait DefaultInvoiceBroadcast +trait DefaultResourceBroadcast { public function broadcastOn(): array { @@ -26,17 +27,40 @@ trait DefaultInvoiceBroadcast ]; } + public function broadcastModel(): BaseModel + { + throw new \LogicException('Make sure to pass a model to the broadcastModel method.'); + } + + public function broadcastManager(Manager $manager): Manager + { + return $manager; + } + public function broadcastWith(): array { + $entity = $this->broadcastModel(); + $manager = new Manager(); + $manager->setSerializer(new ArraySerializer()); - $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->invoice)); + + $class = sprintf('App\\Transformers\\%sTransformer', class_basename($entity)); $transformer = new $class(); - $resource = new Item($this->invoice, $transformer, $this->invoice->getEntityType()); + $resource = new Item($entity, $transformer, $entity->getEntityType()); + + $manager = $this->broadcastManager($manager); + $data = $manager->createData($resource)->toArray(); - return [...$data, 'x-socket-id' => $this->socket]; + $data = [...$data]; + + if (\property_exists($this, 'socket')) { + $data['x-socket-id'] = $this->socket; + } + + return $data; } } From 81971bf195f79960e045d6b78b2088c5e16c7e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 18 Oct 2024 18:32:50 +0200 Subject: [PATCH 09/13] update credit was created --- app/Events/Credit/CreditWasCreated.php | 33 ++++---------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/app/Events/Credit/CreditWasCreated.php b/app/Events/Credit/CreditWasCreated.php index 93a7fbeed1..0824b4d7d1 100644 --- a/app/Events/Credit/CreditWasCreated.php +++ b/app/Events/Credit/CreditWasCreated.php @@ -11,22 +11,21 @@ namespace App\Events\Credit; +use App\Models\BaseModel; use App\Models\Company; use App\Models\Credit; +use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -use League\Fractal\Manager; -use App\Transformers\ArraySerializer; -use League\Fractal\Resource\Item; class CreditWasCreated implements ShouldBroadcast { use Dispatchable; use InteractsWithSockets; use SerializesModels; + use DefaultResourceBroadcast; public $credit; @@ -50,30 +49,8 @@ class CreditWasCreated implements ShouldBroadcast $this->dontBroadcastToCurrentUser(); } - /** - * @inheritDoc - */ - public function broadcastOn() + public function broadcastModel(): BaseModel { - return [ - new PrivateChannel("company-{$this->company->company_key}"), - ]; - } - - /** - * @inheritDoc - */ - public function broadcastWith(): array - { - $manager = new Manager(); - $manager->setSerializer(new ArraySerializer()); - $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->credit)); - - $transformer = new $class(); - - $resource = new Item($this->credit, $transformer, $this->credit->getEntityType()); - $data = $manager->createData($resource)->toArray(); - - return [...$data, 'x-socket-id' => $this->socket]; + return $this->credit; } } From cbb6afb0ba736542fd2dd75b67e17be582d8a63a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 18 Oct 2024 18:33:14 +0200 Subject: [PATCH 10/13] update credit was updated --- app/Events/Credit/CreditWasUpdated.php | 35 +++++--------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/app/Events/Credit/CreditWasUpdated.php b/app/Events/Credit/CreditWasUpdated.php index 977220b1d2..0753a6379f 100644 --- a/app/Events/Credit/CreditWasUpdated.php +++ b/app/Events/Credit/CreditWasUpdated.php @@ -11,22 +11,21 @@ namespace App\Events\Credit; +use App\Models\BaseModel; use App\Models\Company; use App\Models\Credit; +use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -use League\Fractal\Manager; -use App\Transformers\ArraySerializer; -use League\Fractal\Resource\Item; class CreditWasUpdated implements ShouldBroadcast { use Dispatchable; use InteractsWithSockets; use SerializesModels; + use DefaultResourceBroadcast; public $credit; @@ -49,31 +48,9 @@ class CreditWasUpdated implements ShouldBroadcast $this->dontBroadcastToCurrentUser(); } - - /** - * @inheritDoc - */ - public function broadcastOn() + + public function broadcastModel(): BaseModel { - return [ - new PrivateChannel("company-{$this->company->company_key}"), - ]; - } - - /** - * @inheritDoc - */ - public function broadcastWith(): array - { - $manager = new Manager(); - $manager->setSerializer(new ArraySerializer()); - $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->credit)); - - $transformer = new $class(); - - $resource = new Item($this->credit, $transformer, $this->credit->getEntityType()); - $data = $manager->createData($resource)->toArray(); - - return [...$data, 'x-socket-id' => $this->socket]; + return $this->credit; } } From 35a1cd2bf8340a9925316d368b1d7d531cd07914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 18 Oct 2024 18:33:20 +0200 Subject: [PATCH 11/13] update invoice was paid --- app/Events/Invoice/InvoiceWasPaid.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Events/Invoice/InvoiceWasPaid.php b/app/Events/Invoice/InvoiceWasPaid.php index 5bd858aa9b..1897ca5f7c 100644 --- a/app/Events/Invoice/InvoiceWasPaid.php +++ b/app/Events/Invoice/InvoiceWasPaid.php @@ -12,10 +12,11 @@ namespace App\Events\Invoice; +use App\Models\BaseModel; use App\Models\Company; use App\Models\Invoice; use App\Models\Payment; -use App\Utils\Traits\Invoice\Broadcasting\DefaultInvoiceBroadcast; +use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Queue\SerializesModels; @@ -25,7 +26,7 @@ use Illuminate\Queue\SerializesModels; */ class InvoiceWasPaid implements ShouldBroadcast { - use SerializesModels, DefaultInvoiceBroadcast, InteractsWithSockets; + use SerializesModels, DefaultResourceBroadcast, InteractsWithSockets; /** * Create a new event instance. @@ -39,4 +40,9 @@ class InvoiceWasPaid implements ShouldBroadcast { $this->dontBroadcastToCurrentUser(); } + + public function broadcastModel(): BaseModel + { + return $this->invoice; + } } From 439af5aa4254f4f823b088ead06f663200312220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 18 Oct 2024 18:33:25 +0200 Subject: [PATCH 12/13] update invoice was viewed --- app/Events/Invoice/InvoiceWasViewed.php | 26 +++++++------------------ 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/app/Events/Invoice/InvoiceWasViewed.php b/app/Events/Invoice/InvoiceWasViewed.php index 378628bf17..2ea510516d 100644 --- a/app/Events/Invoice/InvoiceWasViewed.php +++ b/app/Events/Invoice/InvoiceWasViewed.php @@ -11,15 +11,14 @@ namespace App\Events\Invoice; +use App\Models\BaseModel; use App\Models\Company; use App\Models\InvoiceInvitation; +use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Queue\SerializesModels; use League\Fractal\Manager; -use App\Transformers\ArraySerializer; -use League\Fractal\Resource\Item; /** * Class InvoiceWasViewed. @@ -28,6 +27,7 @@ class InvoiceWasViewed implements ShouldBroadcast { use SerializesModels; use InteractsWithSockets; + use DefaultResourceBroadcast; /** * Create a new event instance. @@ -41,27 +41,15 @@ class InvoiceWasViewed implements ShouldBroadcast // } - public function broadcastOn(): array + public function broadcastModel(): BaseModel { - return [ - new PrivateChannel("company-{$this->company->company_key}"), - ]; + return $this->invitation->invoice; } - public function broadcastWith(): array + public function broadcastManager(Manager $manager): Manager { - $manager = new Manager(); - $manager->setSerializer(new ArraySerializer()); - $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->invitation->invoice)); - - $transformer = new $class(); - - $resource = new Item($this->invitation->invoice, $transformer, $this->invitation->invoice->getEntityType()); - $manager->parseIncludes('client'); - $data = $manager->createData($resource)->toArray(); - - return $data; + return $manager; } } From 397dd5dee7b81c716b616af889d9088c3a6a4777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 18 Oct 2024 18:33:30 +0200 Subject: [PATCH 13/13] update payment was updated --- app/Events/Payment/PaymentWasUpdated.php | 28 +++++------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/app/Events/Payment/PaymentWasUpdated.php b/app/Events/Payment/PaymentWasUpdated.php index 114c1357d6..66dc574059 100644 --- a/app/Events/Payment/PaymentWasUpdated.php +++ b/app/Events/Payment/PaymentWasUpdated.php @@ -11,22 +11,20 @@ namespace App\Events\Payment; +use App\Models\BaseModel; use App\Models\Company; use App\Models\Payment; -use App\Transformers\ArraySerializer; +use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Queue\SerializesModels; -use League\Fractal\Manager; -use League\Fractal\Resource\Item; /** * Class PaymentWasUpdated. */ class PaymentWasUpdated implements ShouldBroadcast { - use SerializesModels, InteractsWithSockets; + use SerializesModels, InteractsWithSockets, DefaultResourceBroadcast; /** * @var Payment @@ -53,24 +51,8 @@ class PaymentWasUpdated implements ShouldBroadcast $this->dontBroadcastToCurrentUser(); } - public function broadcastOn(): array + public function broadcastModel(): BaseModel { - return [ - new PrivateChannel("company-{$this->company->company_key}"), - ]; - } - - public function broadcastWith(): array - { - $manager = new Manager(); - $manager->setSerializer(new ArraySerializer()); - $class = sprintf('App\\Transformers\\%sTransformer', class_basename($this->payment)); - - $transformer = new $class(); - - $resource = new Item($this->payment, $transformer, $this->payment->getEntityType()); - $data = $manager->createData($resource)->toArray(); - - return [...$data, 'x-socket-id' => $this->socket]; + return $this->payment; } }