| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Module\User\Model;
- use App\Module\Merchant\Model\Merchant;
- use App\Module\User\Enums\PhoneStatus;
- use App\Module\User\Enums\Status;
- use App\Module\User\Enums\Status2;
- use App\Module\User\Model\Events\UserInfoSaved;
- use App\Module\User\Model\Events\UserInfoUpdate;
- use UCore\ModelCore;
- use Illuminate\Database\Eloquent\Relations\HasOne;
- use Illuminate\Database\Eloquent\SoftDeletes;
- /**
- * 用户信息
- *
- * field start
- *
- * @property int $user_id 用户ID
- * @property int $status 状态
- * @property string $google2fa_secret
- * @property string $nickname 昵称
- * @property string $avatar 头像
- * @property \Carbon\Carbon $created_at
- * @property \Carbon\Carbon $updated_at
- * @property \Carbon\Carbon $deleted_at
- * field end
- *
- * Class UserInfo
- * @property UserPhone $user_phone
- */
- class UserInfo extends \App\Models\ModelCore
- {
- use SoftDeletes;
- protected $primaryKey = 'user_id';
- protected $casts = [
- 'status' => Status::class,
- ];
- protected $dispatchesEvents = [
- 'updated' => UserInfoUpdate::class,
- 'saved' => UserInfoSaved::class
- ];
- public function merchant(): HasOne
- {
- return $this->hasOne(Merchant::class, 'user_id', 'user_id')->orderByDesc('id');
- }
- public function user(): HasOne
- {
- return $this->hasOne(User::class, 'id', 'user_id');
- }
- public function user_phone(): HasOne
- {
- return $this->hasOne(UserPhone::class, 'user_id', 'user_id')->where('status', '=', PhoneStatus::BIND);
- }
- }
|