MobileHoldLog.php 962 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\common\model;
  3. use app\admin\model\Admin;
  4. use think\Model;
  5. use Yansongda\Supports\Str;
  6. /**
  7. * 配置模型
  8. */
  9. class MobileHoldLog extends Model
  10. {
  11. protected $autoWriteTimestamp=true;
  12. protected $updateTime=null;
  13. public function holdable(){
  14. return $this->morphTo('holdable',[
  15. 'admin'=>Admin::class,
  16. 'user' =>User::class,
  17. ]);
  18. }
  19. public function mobile(){
  20. return $this->belongsTo(Mobile::class,'mobile_id','id')->setEagerlyType(0);
  21. }
  22. public static function withHoldUser(User $user,$is_hold){
  23. return new self([
  24. 'holdable_type'=>'user',
  25. 'holdable_id'=>$user['id'],
  26. 'is_hold'=>$is_hold,
  27. ]);
  28. }
  29. public static function withHoldAdmin(Admin $user,$is_hold){
  30. return new self([
  31. 'holdable_type'=>'admin',
  32. 'holdable_id'=>$user['id'],
  33. 'is_hold'=>$is_hold,
  34. ]);
  35. }
  36. }