NewsIprecord.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/4
  6. * Time: 上午9:34
  7. */
  8. namespace common\models;
  9. use Yii;
  10. class NewsIprecord extends Common
  11. {
  12. public function rules()
  13. {
  14. return [
  15. // [['ip','nid','region','city','','','',]],
  16. // ['phone_sales', 'string','max'=>'15'],
  17. // ['main_units','string','max'=>80],
  18. // ['longitude_latitude','string','max'=>50],
  19. // ['info','string'],
  20. // [['open_time','launch_time'],'string', 'max'=>50],
  21. //
  22. // [['address','sales_address','land_agent'],'string','max'=>100],
  23. // ['house_cx','string','max'=>50],
  24. ];
  25. }
  26. public function Authenticator($input)
  27. {
  28. $this->load($input,'');
  29. if(!$this->validate()) return $this->errors;
  30. return $this;
  31. }
  32. public function FindById($id)
  33. {
  34. return self::findOne($id);
  35. }
  36. public function FindByIp()
  37. {
  38. $query = self::find();
  39. $query->andWhere(['ip'=>$this->ip]);
  40. $query->andWhere(['nid'=>$this->nid]);
  41. return $query->one();
  42. }
  43. }