1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\common\model;
- use app\admin\model\Admin;
- use think\Model;
- use Yansongda\Supports\Str;
- /**
- * 配置模型
- */
- class MobileHoldLog extends Model
- {
- protected $autoWriteTimestamp=true;
- protected $updateTime=null;
- public function holdable(){
- return $this->morphTo('holdable',[
- 'admin'=>Admin::class,
- 'user' =>User::class,
- ]);
- }
- public function mobile(){
- return $this->belongsTo(Mobile::class,'mobile_id','id')->setEagerlyType(0);
- }
- public static function withHoldUser(User $user,$is_hold){
- return new self([
- 'holdable_type'=>'user',
- 'holdable_id'=>$user['id'],
- 'is_hold'=>$is_hold,
- ]);
- }
- public static function withHoldAdmin(Admin $user,$is_hold){
- return new self([
- 'holdable_type'=>'admin',
- 'holdable_id'=>$user['id'],
- 'is_hold'=>$is_hold,
- ]);
- }
- }
|