123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\models\entity;
- use yii\db\ActiveRecord;
- /**
- * Class Metrics
- * @package app\models\entity
- *
- * @property int $id
- * @property int $type
- * @property string $stamp
- * @property int $num
- * @property string $desc
- * @property-read string $typeString
- */
- class Metrics extends ActiveRecord
- {
- public static function tableName()
- {
- return 'metrics';
- }
- public static function log(int $type = 1, int $num = null, string $desc = null)
- {
- $log = new self();
- $log->type = $type;
- $log->stamp = (new \DateTime())->format('Y-m-d H:i:s');
- $log->num = $num;
- $log->desc = $desc;
- $log->save();
- }
- public function getTypeString()
- {
- switch ($this->type) {
- case 1: return 'Запрос от МП в SMoPP';
- case 2: return 'Запрос в ЕИПП';
- case 3: return 'Ответ от ЕИПП';
- case 4: return 'Ответ СМоПП в МП';
- default: return '';
- }
- }
- }
|