Initial import of animal_management module
This commit is contained in:
43
models/AnimalGalleryLink.php
Normal file
43
models/AnimalGalleryLink.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace humhub\modules\animal_management\models;
|
||||
|
||||
use humhub\components\ActiveRecord;
|
||||
|
||||
class AnimalGalleryLink extends ActiveRecord
|
||||
{
|
||||
public static function tableName()
|
||||
{
|
||||
return 'rescue_animal_gallery_link';
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['animal_id', 'gallery_id', 'contentcontainer_id'], 'required'],
|
||||
[['animal_id', 'gallery_id', 'contentcontainer_id'], 'integer'],
|
||||
[['animal_id'], 'unique'],
|
||||
[['gallery_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;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getAnimal()
|
||||
{
|
||||
return $this->hasOne(Animal::class, ['id' => 'animal_id']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user