Family.php 701 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\Db;
  5. use fast\Random;
  6. /**
  7. * 模型
  8. */
  9. class Family extends Model
  10. {
  11. // 开启自动写入时间戳字段
  12. protected $autoWriteTimestamp = 'int';
  13. // 定义时间戳字段名
  14. protected $createTime = 'createtime';
  15. /**
  16. * 生成不重复的随机数字
  17. */
  18. public static function getUinqueId($length = 4,$ids = []) {
  19. $newid = Random::build("nozero",$length);
  20. if(in_array($newid,$ids)) {
  21. self::getUinqueId(4,$ids);
  22. }
  23. return $newid;
  24. }
  25. public function familymember()
  26. {
  27. return $this->hasMany('FamilyMember', 'guild_id', 'id',[],'LEFT');
  28. }
  29. }