chore: bootstrap module from working instance and add install guide
This commit is contained in:
45
models/DonationSubscription.php
Normal file
45
models/DonationSubscription.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace humhub\modules\donations\models;
|
||||
|
||||
use humhub\components\ActiveRecord;
|
||||
|
||||
class DonationSubscription extends ActiveRecord
|
||||
{
|
||||
public static function tableName()
|
||||
{
|
||||
return 'rescue_donation_subscription';
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['contentcontainer_id', 'provider', 'provider_subscription_id', 'status', 'amount'], 'required'],
|
||||
[['contentcontainer_id', 'donor_user_id', 'goal_id', 'interval_count'], 'integer'],
|
||||
[['amount'], 'number', 'min' => 0.01],
|
||||
[['provider', 'status'], 'string', 'max' => 32],
|
||||
[['provider_subscription_id'], 'string', 'max' => 190],
|
||||
[['currency'], 'string', 'max' => 8],
|
||||
[['interval_unit'], 'string', 'max' => 16],
|
||||
];
|
||||
}
|
||||
|
||||
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->currency)) {
|
||||
$this->currency = 'USD';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user