Banner.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "banner".
  6. *
  7. * @property int $id
  8. * @property int $status 状态
  9. * @property string $title 记录描述
  10. * @property string $primaryKey 关键值
  11. * @property int $admin_id 操作用户ID
  12. * @property string $admin_name 操作用户名
  13. * @property int $addtime 记录时间
  14. * @property string $admin_ip 操作用户IP
  15. * @property string $admin_agent 操作用户浏览器代理商
  16. * @property string $model 操作模块(例:文章)
  17. * @property string $type 操作类型(例:添加)
  18. * @property int $handle_id 操作对象ID
  19. * @property string $result 操作结果
  20. * @property string $describe 备注
  21. */
  22. class Banner extends \yii\db\ActiveRecord
  23. {
  24. const STATUS_DISPLAY = 0;
  25. static $mp_status = [
  26. self::STATUS_DISPLAY => '点击进入未展示',
  27. ];
  28. /**
  29. * @inheritdoc
  30. */
  31. public static function tableName()
  32. {
  33. return 'banner';
  34. }
  35. /**
  36. * @inheritdoc
  37. */
  38. public function rules()
  39. {
  40. return [
  41. [['status', 'title', 'primaryKey', 'admin_id', 'admin_name', 'addtime', 'admin_ip', 'admin_agent', 'model', 'type', 'handle_id', 'result', 'describe'], 'required'],
  42. [['status', 'admin_id', 'addtime', 'handle_id'], 'integer'],
  43. [['result', 'describe'], 'string'],
  44. [['title', 'primaryKey', 'admin_name', 'admin_ip', 'admin_agent', 'model', 'type'], 'string', 'max' => 200],
  45. ];
  46. }
  47. /**
  48. * @inheritdoc
  49. */
  50. public function attributeLabels()
  51. {
  52. return [
  53. 'id' => 'ID',
  54. 'status' => 'Status',
  55. 'title' => 'Title',
  56. 'primaryKey' => 'Primary Key',
  57. 'admin_id' => 'Admin ID',
  58. 'admin_name' => 'Admin Name',
  59. 'addtime' => 'Addtime',
  60. 'admin_ip' => 'Admin Ip',
  61. 'admin_agent' => 'Admin Agent',
  62. 'model' => 'Model',
  63. 'type' => 'Type',
  64. 'handle_id' => 'Handle ID',
  65. 'result' => 'Result',
  66. 'describe' => 'Describe',
  67. ];
  68. }
  69. public function searchById($id){
  70. if (($model = Banner::findOne($id)) !== null) {
  71. return json_encode($model->toArray());
  72. } else {
  73. throw new \yii\web\NotFoundHttpException('The requested page does not exist.');
  74. }
  75. }
  76. }