fix for seeders

This commit is contained in:
paulwer 2023-12-01 12:22:04 +01:00
parent 8a8c3b85c3
commit ef48bd150c

View File

@ -11,7 +11,9 @@
namespace App\Observers;
use App\Jobs\Util\WebhookHandler;
use App\Models\Product;
use App\Models\Webhook;
class ProductObserver
{
@ -24,8 +26,8 @@ class ProductObserver
public function created(Product $product)
{
$subscriptions = Webhook::where('company_id', $product->company->id)
->where('event_id', Webhook::EVENT_CREATE_PRODUCT)
->exists();
->where('event_id', Webhook::EVENT_CREATE_PRODUCT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_PRODUCT, $product, $product->company)->delay(now()->addSeconds(2));
@ -41,8 +43,8 @@ class ProductObserver
public function updated(Product $product)
{
$subscriptions = Webhook::where('company_id', $product->company->id)
->where('event_id', Webhook::EVENT_UPDATE_PRODUCT)
->exists();
->where('event_id', Webhook::EVENT_UPDATE_PRODUCT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_PRODUCT, $product, $product->company)->delay(now()->addSeconds(2));
@ -58,8 +60,8 @@ class ProductObserver
public function deleted(Product $product)
{
$subscriptions = Webhook::where('company_id', $product->company->id)
->where('event_id', Webhook::EVENT_DELETE_PRODUCT)
->exists();
->where('event_id', Webhook::EVENT_DELETE_PRODUCT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_PRODUCT, $product, $product->company)->delay(now()->addSeconds(2));