Merge pull request #8034 from turbo124/v5-develop

Add delete webhook for projects
This commit is contained in:
David Bomba 2022-12-05 12:31:27 +11:00 committed by GitHub
commit 7c57c91f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 482 additions and 404 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));
}
}
/**

873
composer.lock generated

File diff suppressed because it is too large Load Diff