44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace humhub\modules\donations\models;
|
|
|
|
use humhub\components\ActiveRecord;
|
|
|
|
class DonationWebhookEvent extends ActiveRecord
|
|
{
|
|
public static function tableName()
|
|
{
|
|
return 'rescue_donation_webhook_event';
|
|
}
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['provider', 'provider_event_id'], 'required'],
|
|
[['is_processed'], 'integer'],
|
|
[['payload_json'], 'string'],
|
|
[['provider'], 'string', 'max' => 32],
|
|
[['provider_event_id'], 'string', 'max' => 190],
|
|
[['event_type'], 'string', 'max' => 120],
|
|
[['provider', 'provider_event_id'], 'unique', 'targetAttribute' => ['provider', 'provider_event_id']],
|
|
];
|
|
}
|
|
|
|
public function beforeSave($insert)
|
|
{
|
|
if (!parent::beforeSave($insert)) {
|
|
return false;
|
|
}
|
|
|
|
if ($insert && empty($this->created_at)) {
|
|
$this->created_at = date('Y-m-d H:i:s');
|
|
}
|
|
|
|
if ($this->is_processed === null) {
|
|
$this->is_processed = 0;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|