model = $model; } /** * 查找记录 * * @param int $id * @return Test|null */ public function find(int $id): ?Test { return $this->model->find($id); } /** * 创建记录 * * @param array $data * @return Test */ public function create(array $data): Test { return $this->model->create($data); } /** * 更新记录 * * @param int $id * @param array $data * @return bool */ public function update(int $id, array $data): bool { $model = $this->find($id); if (!$model) { return false; } return $model->update($data); } /** * 删除记录 * * @param int $id * @return bool */ public function delete(int $id): bool { $model = $this->find($id); if (!$model) { return false; } return $model->delete(); } }