1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/app/Models/Webhook.php

275 lines
8.0 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2024-04-12 06:15:41 +02:00
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
2023-03-08 08:33:42 +01:00
/**
* App\Models\Webhook
*
* @property int $id
* @property int|null $company_id
* @property int|null $user_id
* @property int|null $event_id
2024-06-15 09:34:08 +02:00
* @property bool $is_deleted
2023-03-08 08:33:42 +01:00
* @property string $target_url
* @property string $format
* @property int|null $created_at
* @property int|null $updated_at
* @property int|null $deleted_at
* @property string|null $rest_method
* @property array|null $headers
* @property-read \App\Models\Company|null $company
* @property-read mixed $hashed_id
* @property-read \App\Models\User|null $user
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Illuminate\Database\Eloquent\Builder|Webhook filter(\App\Filters\QueryFilters $filters)
* @method static \Illuminate\Database\Eloquent\Builder|Webhook newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Webhook newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Webhook onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Webhook query()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
* @method static \Illuminate\Database\Eloquent\Builder|Webhook withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Webhook withoutTrashed()
2023-04-27 00:05:57 +02:00
* @method static \Illuminate\Database\Eloquent\Builder|Webhook where()
2023-03-08 08:33:42 +01:00
* @mixin \Eloquent
*/
2020-07-06 13:22:36 +02:00
class Webhook extends BaseModel
{
use SoftDeletes;
use Filterable;
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_CLIENT = 1; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_INVOICE = 2; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_QUOTE = 3; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_PAYMENT = 4; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_VENDOR = 5; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_QUOTE = 6; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_QUOTE = 7; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_INVOICE = 8; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_INVOICE = 9; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_CLIENT = 10; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_CLIENT = 11; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_PAYMENT = 12; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_VENDOR = 13; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_VENDOR = 14; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_EXPENSE = 15; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_EXPENSE = 16; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_EXPENSE = 17; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_TASK = 18; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_TASK = 19; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_TASK = 20; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_APPROVE_QUOTE = 21; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_LATE_INVOICE = 22;
2024-01-14 05:05:00 +01:00
public const EVENT_EXPIRED_QUOTE = 23;
2024-01-14 05:05:00 +01:00
public const EVENT_REMIND_INVOICE = 24;
2024-01-14 05:05:00 +01:00
public const EVENT_PROJECT_CREATE = 25; //tested
2024-01-14 05:05:00 +01:00
public const EVENT_PROJECT_UPDATE = 26; //tested
2022-04-14 13:38:29 +02:00
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_CREDIT = 27; //tested
2022-09-15 09:43:33 +02:00
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_CREDIT = 28; //tested
2022-09-15 09:43:33 +02:00
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_CREDIT = 29; //tested
2022-09-15 09:43:33 +02:00
2024-01-14 05:05:00 +01:00
public const EVENT_PROJECT_DELETE = 30; //tested
2022-12-05 02:30:58 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_PAYMENT = 31; //tested
2023-01-08 12:36:14 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_PAYMENT = 32; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_INVOICE = 33; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_QUOTE = 34; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_CREDIT = 35; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_TASK = 36; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_CLIENT = 37; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_PROJECT = 38; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_EXPENSE = 39; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_PAYMENT = 40; //tested
2023-01-30 08:26:32 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_INVOICE = 41; //tested
2023-01-30 08:26:32 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_QUOTE = 42; ///tested
2023-01-30 08:26:32 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_CREDIT = 43; //tested
2023-01-30 08:26:32 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_TASK = 44; //tested
2023-01-30 08:26:32 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_CLIENT = 45; //tested
2023-01-30 08:26:32 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_PROJECT = 46; //tested
2023-01-30 08:26:32 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_EXPENSE = 47; //tested
2023-01-30 08:26:32 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_VENDOR = 48; //tested
2023-01-31 08:59:02 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_VENDOR = 49; //tested
2023-01-31 08:59:02 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_PRODUCT = 50; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_PRODUCT = 51; //tested
2023-01-29 14:43:57 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_PRODUCT = 52; //tested
2023-01-08 12:36:14 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_PRODUCT = 53; //tested
2023-01-31 13:53:54 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_PRODUCT = 54; //tested
2023-01-31 13:53:54 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_CREATE_PURCHASE_ORDER = 55; //tested
2023-01-31 13:53:54 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_UPDATE_PURCHASE_ORDER = 56; //tested
2023-01-31 13:53:54 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_DELETE_PURCHASE_ORDER = 57; //tested
2023-01-31 13:53:54 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_RESTORE_PURCHASE_ORDER = 58; //tested
2023-01-31 13:53:54 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_ARCHIVE_PURCHASE_ORDER = 59; //tested
2022-12-05 02:30:58 +01:00
2024-01-14 05:05:00 +01:00
public const EVENT_SENT_INVOICE = 60;
2024-01-14 05:05:00 +01:00
public const EVENT_SENT_QUOTE = 61;
2024-01-14 05:05:00 +01:00
public const EVENT_SENT_CREDIT = 62;
2024-01-14 05:05:00 +01:00
public const EVENT_SENT_PURCHASE_ORDER = 63;
2024-06-21 11:40:56 +02:00
public const EVENT_REMIND_QUOTE = 64;
2024-08-21 01:35:54 +02:00
public const EVENT_ACCEPTED_PURCHASE_ORDER = 65;
public static $valid_events = [
2024-08-21 01:35:54 +02:00
self::EVENT_ACCEPTED_PURCHASE_ORDER,
2024-06-21 11:40:56 +02:00
self::EVENT_REMIND_QUOTE,
2023-01-31 13:53:54 +01:00
self::EVENT_CREATE_PURCHASE_ORDER,
self::EVENT_UPDATE_PURCHASE_ORDER,
self::EVENT_DELETE_PURCHASE_ORDER,
self::EVENT_RESTORE_PURCHASE_ORDER,
self::EVENT_ARCHIVE_PURCHASE_ORDER,
2024-03-07 07:03:09 +01:00
self::EVENT_CREATE_PRODUCT,
2023-01-31 13:53:54 +01:00
self::EVENT_UPDATE_PRODUCT,
self::EVENT_DELETE_PRODUCT,
self::EVENT_RESTORE_PRODUCT,
self::EVENT_ARCHIVE_PRODUCT,
self::EVENT_CREATE_CLIENT,
self::EVENT_CREATE_INVOICE,
self::EVENT_CREATE_QUOTE,
self::EVENT_CREATE_PAYMENT,
self::EVENT_CREATE_VENDOR,
self::EVENT_UPDATE_QUOTE,
self::EVENT_DELETE_QUOTE,
self::EVENT_UPDATE_INVOICE,
self::EVENT_DELETE_INVOICE,
self::EVENT_UPDATE_CLIENT,
self::EVENT_DELETE_CLIENT,
self::EVENT_DELETE_PAYMENT,
self::EVENT_UPDATE_VENDOR,
self::EVENT_DELETE_VENDOR,
self::EVENT_CREATE_EXPENSE,
self::EVENT_UPDATE_EXPENSE,
self::EVENT_DELETE_EXPENSE,
self::EVENT_CREATE_TASK,
self::EVENT_UPDATE_TASK,
self::EVENT_DELETE_TASK,
self::EVENT_APPROVE_QUOTE,
self::EVENT_LATE_INVOICE,
self::EVENT_EXPIRED_QUOTE,
self::EVENT_REMIND_INVOICE,
2022-04-14 13:38:29 +02:00
self::EVENT_PROJECT_CREATE,
self::EVENT_PROJECT_UPDATE,
2022-09-15 09:43:33 +02:00
self::EVENT_CREATE_CREDIT,
self::EVENT_UPDATE_CREDIT,
self::EVENT_DELETE_CREDIT,
2023-01-08 12:36:14 +01:00
self::EVENT_PROJECT_DELETE,
2023-01-27 14:25:33 +01:00
self::EVENT_UPDATE_PAYMENT,
self::EVENT_ARCHIVE_EXPENSE,
self::EVENT_ARCHIVE_PROJECT,
self::EVENT_ARCHIVE_CLIENT,
self::EVENT_ARCHIVE_TASK,
self::EVENT_ARCHIVE_CREDIT,
self::EVENT_ARCHIVE_QUOTE,
2023-01-29 14:43:57 +01:00
self::EVENT_ARCHIVE_INVOICE,
2023-01-30 08:26:32 +01:00
self::EVENT_ARCHIVE_PAYMENT,
2023-01-31 08:59:02 +01:00
self::EVENT_ARCHIVE_VENDOR,
2023-01-30 08:26:32 +01:00
self::EVENT_RESTORE_EXPENSE,
self::EVENT_RESTORE_PROJECT,
self::EVENT_RESTORE_CLIENT,
self::EVENT_RESTORE_TASK,
self::EVENT_RESTORE_CREDIT,
self::EVENT_RESTORE_QUOTE,
self::EVENT_RESTORE_INVOICE,
2023-01-31 08:59:02 +01:00
self::EVENT_RESTORE_PAYMENT,
self::EVENT_RESTORE_VENDOR,
self::EVENT_SENT_INVOICE,
self::EVENT_SENT_QUOTE,
self::EVENT_SENT_CREDIT,
self::EVENT_SENT_PURCHASE_ORDER
2023-01-29 14:43:57 +01:00
];
protected $fillable = [
'target_url',
'format',
'event_id',
'rest_method',
'headers',
];
protected $casts = [
'headers' => 'array',
2021-04-06 00:19:27 +02:00
'updated_at' => 'timestamp',
'created_at' => 'timestamp',
'deleted_at' => 'timestamp',
];
2023-08-02 11:47:26 +02:00
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class)->withTrashed();
}
2023-08-02 11:47:26 +02:00
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Company::class);
}
}