belongsTo('app\\common\\model\\user\\User'); } /** * 关联等级 * @return \think\model\relation\BelongsTo */ public function grade() { return $this->belongsTo('app\\common\\model\\plus\\release\\Grade','grade_id','grade_id'); } /** * 详情 */ public static function detail($user_id, $with = ['user']) { return (new static())->with($with)->find($user_id); } /** * 详情 */ public static function getAll() { return (new static())->where("is_delete","=",0)->select(); } /** * 是否为供应方 */ public static function isSupplyUser($user_id) { $supply = self::detail($user_id); return !!$supply && !$supply['is_delete']; } /** * 新增记录 * @param $user_id * @param $data * @return bool */ public static function add($user_id, $data) { $model = static::detail($user_id) ?: new static; $model->save(array_merge([ 'user_id' => $user_id, 'is_delete' => 0, 'app_id' => $model::$app_id, ], $data)); return true; } }