repository = $repository; } /** * @return mixed 列表 * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException * @author xaboy * @day 2020-03-31 */ public function lst() { $lst = $this->repository->lst(); // $lst['list'] = $lst['list']->toArray(); return app('json')->success($lst); } /** * @return mixed 创建表单 * @throws FormBuilderException * @author xaboy * @day 2020-03-31 */ public function createTable() { $form = $this->repository->createForm(); return app('json')->success(formToData($form)); } /** 修改表单 * @param int $id * @return mixed * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException * @throws FormBuilderException * @author xaboy * @day 2020-03-31 */ public function updateTable($id) { if (!$this->repository->exists($id)) app('json')->fail('数据不存在'); $form = $this->repository->updateForm($id); return app('json')->success(formToData($form)); } /** 创建 * @return mixed * @author xaboy * @day 2020-03-27 */ public function create() { $data = $this->request->params(['title', 'start', 'end', 'type', 'jd', 'value']); $this->repository->create($data); return app('json')->success('添加成功'); } /**修改 * @param int $id * @return mixed * @throws DbException * @author xaboy * @day 2020-03-27 */ public function update($id) { $data = $this->request->params(['title', 'start', 'end', 'type', 'jd', 'value']); $this->repository->update($id, $data); return app('json')->success('修改成功'); } /** 删除 * @param int $id * @return mixed * @throws DbException * @author xaboy * @day 2020-03-27 */ public function delete($id) { $this->repository->delete($id); return app('json')->success('删除成功'); } }