2023-01-20 05:55:05 +01:00
|
|
|
<?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)
|
2023-01-20 05:55:05 +01:00
|
|
|
*
|
|
|
|
* @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();
|
|
|
|
|
2023-01-22 07:46:56 +01:00
|
|
|
PurchaseOrderInvitation::withTrashed()->where('vendor_contact_id', $vendor_contact_id)->cursor()->each(function ($invite){
|
2023-01-20 05:55:05 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|