每一次安裝之后都要從頭開始,很煩,記錄需要改動的地方
### Curd的更改
#### 增加
~~~
?public function add()
? ? {
??
? ? ? ? ?if ($this->request->isPost()) {
? ? ? ? ? ? ?$post = $this->request->post();
? ? ? ? ? ? ?$rule = [];
? ? ? ? ? ? ?$this->validate($post, $rule);
? ? ? ? ? ? ?try {
? ? ? ? ? ? ? ? ?$save = $this->modelClass->save($post);
? ? ? ? ? ? } catch (\Exception $e) {
? ? ? ? ? ? ? ? ?$this->error('保存失敗');
? ? ? ? ? ? }
? ? ? ? ? ? ?$save ? $this->success('保存成功', ?url('index')) : $this->error('保存失敗');
? ? ? ? }
??
? ? ? ? ?$view = [
? ? ? ? ? ? ?'info' => null,
? ? ? ? ? ? ?'title' => '添加'
? ? ? ? ];
??
? ? ? ? ?return view('', $view);
??
? ? }
~~~
#### 編輯
~~~
??
? ? ?public function edit($id)
? ? { ? ?
? ? ? ? ?$list = $this->modelClass->find($id);
? ? ? ? ?if (empty($list)) $this->error('data is not exist');
? ? ? ? ?if ($this->request->isPost()) {
? ? ? ? ? ? ?$post = $this->request->post();
? ? ? ? ? ? ?$rule = [];
? ? ? ? ? ? ?$this->validate($post, $rule);
? ? ? ? ? ? ?try {
? ? ? ? ? ? ? ? ?$save = $list->save($post);
? ? ? ? ? ? } catch (\Exception $e) {
? ? ? ? ? ? ? ? ?$this->error('保存失敗');
? ? ? ? ? ? }
? ? ? ? ? ? ?$save ? $this->success('保存成功', url('index')) : $this->error('保存失敗');
? ? ? ? }
??
? ? ? ? ?$view = [
? ? ? ? ? ? ?'info' => $list,
? ? ? ? ? ? ?'title' => '編輯'
? ? ? ? ];
??
? ? ? ? ?return view('add', $view);
? ? }
~~~
- 介紹
- PHP
- 過濾
- 訪問第三方
- 封裝概率
- 將反斜杠轉成正斜杠
- 超長數字運算
- php高級
- 設計模式
- TP筆記
- tp5
- TP
- 時間操作
- 模型
- Base函數
- 字符串數組操作
- 數據庫
- 查詢
- 其它操作
- 文件類操作
- 上傳
- 導出
- 壓縮
- tp6
- 封裝上傳方法
- 瀏覽器下載文件
- deepin踩坑
- mysql安裝相關
- layui
- layui表格操作
- layui表格點擊圖片放大
- layui點擊數據表格添加或刪除一行
- layui表格操作
- lemocms
- html相關
- 按鈕
- js
- crud的js函數
- base相關函數
- layui關閉彈窗層并刷新父窗口
- 表單操作
- h5+js
- layui圖片上傳和預覽
- 多圖上傳
- 自定義
- vscode
- vs更換電腦時,同步配置
- 前端
- vue-admin后臺
- 相關操作
- js相關
- js播報語音
- js監聽頁面掃碼槍
- fastadmin
- fast的js
- Typora
- 數據庫
- MySQL