chore: bootstrap module from working instance and add install guide
This commit is contained in:
46
models/DonationBlock.php
Normal file
46
models/DonationBlock.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace humhub\modules\donations\models;
|
||||
|
||||
use humhub\components\ActiveRecord;
|
||||
|
||||
class DonationBlock extends ActiveRecord
|
||||
{
|
||||
public static function tableName()
|
||||
{
|
||||
return 'rescue_donation_block';
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['contentcontainer_id', 'placement'], 'required'],
|
||||
[['contentcontainer_id', 'goal_id', 'is_active', 'sort_order'], 'integer'],
|
||||
[['placement'], 'string', 'max' => 64],
|
||||
[['header'], 'string', 'max' => 190],
|
||||
];
|
||||
}
|
||||
|
||||
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 ($this->sort_order === null) {
|
||||
$this->sort_order = 100;
|
||||
}
|
||||
|
||||
if ($this->is_active === null) {
|
||||
$this->is_active = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user