AdLocation.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%AD_LOCATION}}".
  6. *
  7. * @property string $ID
  8. * @property string $LOCATION_NAME 分类名
  9. * @property string $REMARK 状态
  10. * @property int $TYPE 类型
  11. * @property string $CREATE_ADMIN 创建管理员
  12. * @property string $UPDATE_ADMIN 更新管理员
  13. * @property int $CREATED_AT 创建时间
  14. * @property int $UPDATED_AT 更新时间
  15. */
  16. class AdLocation extends \common\components\ActiveRecord
  17. {
  18. const TYPE_SLIDE = 1;
  19. const TYPE_IMAGE = 2;
  20. /**
  21. * @inheritdoc
  22. */
  23. public static function tableName()
  24. {
  25. return '{{%AD_LOCATION}}';
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['LOCATION_NAME', 'REMARK', 'TYPE', 'CREATE_ADMIN', 'CREATED_AT'], 'required'],
  34. [['TYPE', 'CREATED_AT', 'UPDATED_AT'], 'integer'],
  35. [['ID', 'CREATE_ADMIN', 'UPDATE_ADMIN'], 'string', 'max' => 32],
  36. [['LOCATION_NAME'], 'string', 'max' => 48],
  37. [['REMARK'], 'string', 'max' => 255],
  38. [['LOCATION_NAME'], 'unique'],
  39. [['ID'], 'unique'],
  40. ];
  41. }
  42. /**
  43. * @inheritdoc
  44. */
  45. public function attributeLabels()
  46. {
  47. return [
  48. 'ID' => 'ID',
  49. 'LOCATION_NAME' => '分类名',
  50. 'REMARK' => '状态',
  51. 'TYPE' => '类型',
  52. 'CREATE_ADMIN' => '创建管理员',
  53. 'UPDATE_ADMIN' => '更新管理员',
  54. 'CREATED_AT' => '创建时间',
  55. 'UPDATED_AT' => '更新时间',
  56. ];
  57. }
  58. /**
  59. * 获取全部广告为
  60. * @return array
  61. */
  62. public static function getAllLocation(){
  63. return static::find()->where('1=1')->orderBy('CREATED_AT DESC')->indexBy('ID')->asArray()->all();
  64. }
  65. }