// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\api\model; /** * Class Store * @package app\store\model */ class Square extends \app\common\model\Square { /** * 更新记录 * @param array $data * @return bool */ public function edit(array $data): bool { // 是否删除图片 //!isset($data['logo_image_id']) && $data['logo_image_id'] = 0; return $this->save($data) !== false; } /** * 详情信息 * @param int $storeId * @return static|array|null */ public static function detail(int $squareId, $store_id = 0) { $store_id = $store_id ? $store_id : self::$storeId; $where = [ 'square_id' => $squareId, 'store_id' => $store_id ]; return static::get($where, []); } /** * 新增记录 * @param array $data * @return bool */ public function add(array $data): bool { return $this->save($this->createData($data)); } /** * 创建数据 * @param array $data * @return array */ private function createData(array $data): array { $data['store_id'] = self::$storeId; return $data; } /** * 软删除 * @return bool */ public function setDelete(): bool { return $this->save(['is_delete' => 1]); } }