Implemented webhooks database structure and console command register webhooks

This commit is contained in:
ErickSkrauch
2018-07-07 15:01:18 +03:00
parent 03bd5ec144
commit 6751eb6591
7 changed files with 228 additions and 21 deletions

42
common/models/WebHook.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace common\models;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveQueryInterface;
use yii\db\ActiveRecord;
/**
* Fields:
* @property int $id
* @property string $url
* @property string|null $secret
* @property int $created_at
*
* Relations:
* @property WebHookEvent[] $events
*
* Behaviors:
* @mixin TimestampBehavior
*/
class WebHook extends ActiveRecord {
public static function tableName(): string {
return '{{%webhooks}}';
}
public function behaviors(): array {
return [
[
'class' => TimestampBehavior::class,
'updatedAtAttribute' => false,
],
];
}
public function getEvents(): ActiveQueryInterface {
return $this->hasMany(WebHookEvent::class, ['webhook_id' => 'id']);
}
}