SystemLog.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. namespace fecadmin\models;
  10. use Yii;
  11. use fec\helpers\CDate;
  12. use yii\db\ActiveRecord;
  13. /**
  14. * User model
  15. *
  16. * @property integer $id
  17. * @property string $username
  18. * @property string $password_hash
  19. * @property string $password_reset_token
  20. * @property string $email
  21. * @property string $auth_key
  22. * @property integer $status
  23. * @property integer $created_at
  24. * @property integer $updated_at
  25. * @property string $password write-only password
  26. */
  27. /**
  28. * @author Terry Zhao <2358269014@qq.com>
  29. * @since 1.0
  30. */
  31. class SystemLog extends ActiveRecord
  32. {
  33. /**
  34. * @inheritdoc
  35. */
  36. # 设置table
  37. public static function tableName()
  38. {
  39. return '{{%system_log}}';
  40. }
  41. /**
  42. * @inheritdoc
  43. */
  44. # 设置 status 默认 ,以及取值的区间
  45. public function rules()
  46. {
  47. return [
  48. ];
  49. }
  50. public function beforeSave($insert)
  51. {
  52. if (parent::beforeSave($insert)) {
  53. if($insert == self::EVENT_BEFORE_INSERT){
  54. $user = Yii::$app->user->identity;
  55. $account = $user['username'];
  56. $this->created_person = $account;
  57. $this->created_at = CDate::getCurrentDateTime();
  58. }else{
  59. }
  60. $this->updated_at = CDate::getCurrentDateTime();
  61. return true;
  62. } else {
  63. return false;
  64. }
  65. }
  66. }