1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Observers/VendorContactObserver.php

81 lines
1.9 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Observers;
use App\Models\PurchaseOrderInvitation;
use App\Models\VendorContact;
class VendorContactObserver
{
/**
* Handle the vendor contact "created" event.
*
* @param VendorContact $vendorContact
* @return void
*/
public function created(VendorContact $vendorContact)
{
//
}
/**
* Handle the vendor contact "updated" event.
*
* @param VendorContact $vendorContact
* @return void
*/
public function updated(VendorContact $vendorContact)
{
//
}
/**
* Handle the vendor contact "deleted" event.
*
* @param VendorContact $vendorContact
* @return void
*/
public function deleted(VendorContact $vendorContact)
{
$vendor_contact_id = $vendorContact->id;
$vendorContact->purchase_order_invitations()->delete();
2024-01-14 05:05:00 +01:00
2023-02-16 02:36:09 +01:00
PurchaseOrderInvitation::withTrashed()->where('vendor_contact_id', $vendor_contact_id)->cursor()->each(function ($invite) {
if ($invite->purchase_order()->doesnthave('invitations')) {
$invite->purchase_order->service()->createInvitations();
}
});
}
/**
* Handle the vendor contact "restored" event.
*
* @param VendorContact $vendorContact
* @return void
*/
public function restored(VendorContact $vendorContact)
{
}
/**
* Handle the vendor contact "force deleted" event.
*
* @param VendorContact $vendorContact
* @return void
*/
public function forceDeleted(VendorContact $vendorContact)
{
//
}
}