Add delete webhook for projects

This commit is contained in:
David Bomba 2022-12-05 12:30:58 +11:00
parent aac14ea1e5
commit 855206fb15
2 changed files with 12 additions and 1 deletions

View File

@ -76,6 +76,9 @@ class Webhook extends BaseModel
const EVENT_DELETE_CREDIT = 29;
const EVENT_PROJECT_DELETE = 30;
public static $valid_events = [
self::EVENT_CREATE_CLIENT,
self::EVENT_CREATE_INVOICE,
@ -106,6 +109,7 @@ class Webhook extends BaseModel
self::EVENT_CREATE_CREDIT,
self::EVENT_UPDATE_CREDIT,
self::EVENT_DELETE_CREDIT,
self::EVENT_PROJECT_DELETE
];
protected $fillable = [

View File

@ -61,7 +61,14 @@ class ProjectObserver
*/
public function deleted(Project $project)
{
//
//EVENT_PROJECT_DELETE
$subscriptions = Webhook::where('company_id', $project->company_id)
->where('event_id', Webhook::EVENT_PROJECT_DELETE)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_PROJECT_DELETE, $project, $project->company, 'client')->delay(now()->addSeconds(2));
}
}
/**