45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace humhub\modules\donations\models;
|
|
|
|
use humhub\components\ActiveRecord;
|
|
|
|
class DonationProviderConfig extends ActiveRecord
|
|
{
|
|
public static function tableName()
|
|
{
|
|
return 'rescue_donation_provider_config';
|
|
}
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['contentcontainer_id'], 'required'],
|
|
[['contentcontainer_id'], 'integer'],
|
|
[['paypal_enabled', 'paypal_recurring_enabled', 'stripe_enabled', 'stripe_recurring_enabled', 'sandbox_mode'], 'boolean'],
|
|
[['paypal_client_id', 'paypal_client_secret', 'paypal_webhook_id', 'stripe_publishable_key', 'stripe_secret_key', 'stripe_webhook_secret'], 'string', 'max' => 255],
|
|
[['default_currency'], 'string', 'max' => 8],
|
|
[['contentcontainer_id'], 'unique'],
|
|
];
|
|
}
|
|
|
|
public function beforeSave($insert)
|
|
{
|
|
if (!parent::beforeSave($insert)) {
|
|
return false;
|
|
}
|
|
|
|
$now = date('Y-m-d H:i:s');
|
|
if ($insert && empty($this->created_at)) {
|
|
$this->created_at = $now;
|
|
}
|
|
$this->updated_at = $now;
|
|
|
|
if (empty($this->default_currency)) {
|
|
$this->default_currency = 'USD';
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|