hasOne(Business::class, 'code',"business_code"); } public function couponType() { return $this->hasOne(CouponType::class, 'id',"type_id"); } public static function onAfterInsert( $obj) { $obj->sort = $obj->id; $obj->save(); } }