|
@@ -2,167 +2,40 @@
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
+use App\Enums\TechnicianStatus;
|
|
|
+use App\Traits\HasStateText;
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
use Slowlyo\OwlAdmin\Models\BaseModel as Model;
|
|
|
|
|
|
/**
|
|
|
- * 技师
|
|
|
+ * 技师用户模型
|
|
|
*/
|
|
|
class CoachUser extends Model
|
|
|
{
|
|
|
- use SoftDeletes;
|
|
|
+ use HasStateText, SoftDeletes;
|
|
|
|
|
|
protected $table = 'coach_users';
|
|
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
- protected static function booted()
|
|
|
- {
|
|
|
- static::created(function ($user) {
|
|
|
- $user->wallet()->create([
|
|
|
- 'owner_type' => CoachUser::class,
|
|
|
- 'owner_id' => $user->id,
|
|
|
- ]);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师所属会员
|
|
|
+ * 状态枚举类
|
|
|
*/
|
|
|
- public function member()
|
|
|
- {
|
|
|
- return $this->belongsTo('App\Models\MemberUser', 'user_id');
|
|
|
- }
|
|
|
+ protected string $stateEnumClass = TechnicianStatus::class;
|
|
|
|
|
|
/**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联信息
|
|
|
+ * 获取技师的基本信息
|
|
|
*/
|
|
|
public function info()
|
|
|
{
|
|
|
- return $this->hasOne('App\Models\CoachInfoRecord', 'id', 'info_record_id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联资质信息
|
|
|
- */
|
|
|
- public function qual()
|
|
|
- {
|
|
|
- return $this->hasOne('App\Models\CoachQualRecord', 'id', 'qualification_record_id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联评分
|
|
|
- */
|
|
|
- public function score()
|
|
|
- {
|
|
|
- return $this->hasOne('App\Models\CoachScore', 'coach_id', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联定位
|
|
|
- */
|
|
|
- public function locations()
|
|
|
- {
|
|
|
- return $this->hasMany('App\Models\CoachLocation', 'coach_id', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联抢单记录
|
|
|
- */
|
|
|
- public function grabRecords()
|
|
|
- {
|
|
|
- return $this->hasMany('App\Models\OrderGrabRecord', 'coach_id', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联评论
|
|
|
- */
|
|
|
- public function comments()
|
|
|
- {
|
|
|
- return $this->hasMany('App\Models\OrderComment', 'coach_id', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师所属店铺
|
|
|
- */
|
|
|
- public function shop()
|
|
|
- {
|
|
|
- return $this->belongsTo('App\Models\ShopInfo', 'shop_id', 'shop_id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联店铺开通服务
|
|
|
- */
|
|
|
- public function shopOpenService()
|
|
|
- {
|
|
|
- return $this->hasMany('App\Models\ShopCoachService', 'coach_id', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联实名信息
|
|
|
- */
|
|
|
- public function real()
|
|
|
- {
|
|
|
- return $this->hasOne('App\Models\CoachRealRecord', 'id', 'real_auth_record_id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师开通项目
|
|
|
- */
|
|
|
- public function projects()
|
|
|
- {
|
|
|
- return $this->hasMany('App\Models\CoachProject', 'coach_id', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 基本信息认证记录
|
|
|
- */
|
|
|
- public function infoRecords()
|
|
|
- {
|
|
|
- return $this->hasMany('App\Models\CoachInfoRecord', 'coach_id', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联资质记录
|
|
|
- */
|
|
|
- public function qualRecords()
|
|
|
- {
|
|
|
- return $this->hasMany('App\Models\CoachQualRecord', 'coach_id', 'id');
|
|
|
+ return $this->belongsTo(CoachInfoRecord::class, 'info_record_id');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Author FelixYin
|
|
|
- *
|
|
|
- * @description 技师关联实名认证记录
|
|
|
+ * 获取技师关联的用户
|
|
|
*/
|
|
|
- public function realAuthRecords()
|
|
|
+ public function user()
|
|
|
{
|
|
|
- return $this->hasMany('App\Models\CoachRealAuthRecord', 'coach_id', 'id');
|
|
|
+ return $this->belongsTo(MemberUser::class, 'user_id');
|
|
|
}
|
|
|
}
|