hasOne(Coupon::class, 'coupon_id', 'coupon_id'); } /** * @notes:新增 * @param $data * @return bool * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException * @author: wanghousheng */ public function add($data): bool { if ($this->where(['store_id' => self::$storeId])->find()) { return $this->where(['store_id' => self::$storeId])->save($data) !== false; } $data['store_id'] = self::$storeId; return $this->save($data); } /** * 详情 * @param array $where * @param array $with * @return static|array|null */ public static function detail(array $where = [], array $with = []) { return self::get($where, $with); } }