Eventlog.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "eventlog".
  6. *
  7. * @property integer $id
  8. * @property string $ip
  9. * @property integer $user_id
  10. * @property integer $auk_id
  11. * @property string $action
  12. * @property string $date
  13. */
  14. class Eventlog extends \yii\db\ActiveRecord
  15. {
  16. /**
  17. * @inheritdoc
  18. */
  19. public static function tableName()
  20. {
  21. return 'eventlog';
  22. }
  23. /**
  24. * @inheritdoc
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['ip', 'user_id', 'auk_id', 'action', 'date'], 'required'],
  30. [['user_id', 'auk_id'], 'integer'],
  31. [['date'], 'safe'],
  32. [['ip'], 'string', 'max' => 20],
  33. [['action'], 'string', 'max' => 255],
  34. ];
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'id' => 'ID',
  43. 'ip' => Yii::t('app','Ip ID'),
  44. 'user_id' => Yii::t('app','User ID'),
  45. 'auk_id' => Yii::t('app','TradeLog'),
  46. 'action' => Yii::t('app','Action ID'),
  47. 'date' => Yii::t('app','Date'),
  48. 'at_org' => Yii::t('app','User ID'),
  49. 'name' => Yii::t('app','AukName ID'),
  50. ];
  51. }
  52. public function PutLog($insert)
  53. {
  54. $model = new Eventlog();
  55. $model->setAttributes([
  56. 'user_id' => $insert['user_id'],
  57. 'ip' => $insert['ip'],
  58. 'auk_id' => isset($insert['auk_id'] ) ? $insert['auk_id'] : '',
  59. 'action' => $insert['action'],
  60. 'date' => date("Y-m-d H:i:s"),
  61. ]);
  62. $model->save(false);
  63. return true;
  64. }
  65. function getUser()
  66. {
  67. return $this->hasOne(User::className(),['id' => 'user_id']);
  68. }
  69. function getAuctions()
  70. {
  71. return $this->hasOne(Auctions::className(),['id' => 'auk_id']);
  72. }
  73. public function getLots()
  74. {
  75. return $this->hasOne(Lots::className(), ['id' => 'lot_id'])->via('auctions');
  76. }
  77. /**
  78. * @inheritdoc
  79. * @return EventlogQuery the active query used by this AR class.
  80. */
  81. public static function find()
  82. {
  83. return new EventlogQuery(get_called_class());
  84. }
  85. }