Config.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/4
  6. * Time: 上午9:31
  7. */
  8. namespace common\models;
  9. //use yii\db\ActiveRecord;
  10. //use yii\behaviors\TimestampBehavior;
  11. class Config extends Common
  12. {
  13. // public function behaviors()
  14. // {
  15. // return [
  16. // [
  17. // 'class' => TimestampBehavior::className(),
  18. // 'attributes' => [
  19. // # 创建之前
  20. // ActiveRecord::EVENT_BEFORE_INSERT => ['create_at', 'update_at'],
  21. // # 修改之前
  22. // ActiveRecord::EVENT_BEFORE_UPDATE => ['update_at']
  23. // ],
  24. // #设置默认值
  25. // 'value' => $_SERVER['REQUEST_TIME']
  26. // ]
  27. // ];
  28. // }
  29. public function rules()
  30. {
  31. return [
  32. ['title', 'required', 'message' => '不能为空'],
  33. ['tel', 'string', 'max' => 20],
  34. [['wechat', 'logo', 'email', 'title', 'record', 'operating_hours'], 'string', 'max' => 50],
  35. [['keywords', 'bridge_code', 'statistics', 'm_statistics', 'master_360', 'bridge_link', 'description', 'disclaimer'], 'string', 'max' => 100000]
  36. ];
  37. }
  38. public function attributeLabels()
  39. {
  40. return [
  41. 'title' => '网站标题',
  42. 'keywords' => '网站关键词',
  43. 'description' => '网站描述',
  44. 'wechat' => '微信二维码',
  45. 'logo' => '网站logo',
  46. 'tel' => '服务电话',
  47. 'email' => 'E-mail',
  48. 'record' => '备案号',
  49. 'bridge_link' => '53快服',
  50. 'operating_hours' => '工作时间',
  51. 'baidu_ak' => '百度地图ak',
  52. 'bridge_code' => '商桥代码',
  53. 'statistics' => 'PC端友盟代码',
  54. 'm_statistics' => '移动端友盟代码',
  55. 'master_360' => '360站长代码',
  56. 'disclaimer' => '免责声明',
  57. ];
  58. }
  59. public function FindById()
  60. {
  61. return self::find()->one();
  62. }
  63. }