ThinkPHP6?? ?? ????? ???? ??? ??????
Jun 12, 2023 am 09:31 AM???? ??? ?? ?? ? ?? ???? ?? ??? ?? ???? ???? ???? ???, ?? ?? ??? ?? ?? ? ???? ???? ?? ??? ?? ???? ?? ???? ??? ???. PHP ???? ThinkPHP6 ?????? ??? ?? ???? ?? ??? ?????. ? ????? ThinkPHP6?? ?? ???? ??? ???? ??? ?????.
1. ThinkPHP6? ?? ???? ?? ?? ????
ThinkPHP6? ?? ???? ?? ?? ????? ????? ? ?? ??? ???? ???? ???.
- ???? ???: ??? ???? ??, ???, ?? ?? ? ?? ????? ?? ??
- ?? ???: ??, ??, ????, ?? ?? ?? ???? ?? ????? ?? ?? ??? ?????. ? ?? ??.
?? ???? ?? ????? ??? ?? ???? ??? ? ????.
- ?? ???? ??: ???? ??????? ?? ????? ???? ? ?? ??? ??, ??? ? ?? ??? ?????. : ???? ??? ???? ?? ????? ?? ???? ??? ?????.
- ?? ????? ?? ??: ???? ???? ?? ???? ??? ??? ???? ???? ???? ?????.
- ?? ??: ??? ?? ?? ???? ?? ??? ?? ?????.
- 2. ???? ???? ?? ??? ??
?? ??????? ???? ???? ?? ???? ???? ???.
???? ???:
CREATE TABLE `tp_flow` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(50) DEFAULT NULL COMMENT '流程名稱', `create_user_id` int(11) DEFAULT NULL COMMENT '創(chuàng)建人ID', `create_time` datetime DEFAULT NULL COMMENT '創(chuàng)建時(shí)間', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='審核流程表';
?? ???:
CREATE TABLE `tp_step` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', `flow_id` int(11) DEFAULT NULL COMMENT '流程ID', `name` varchar(50) DEFAULT NULL COMMENT '步驟名稱', `status` tinyint(1) DEFAULT '0' COMMENT '狀態(tài):0-未處理,1-已處理', `handler_id` int(11) DEFAULT NULL COMMENT '處理人ID', `handle_time` datetime DEFAULT NULL COMMENT '處理時(shí)間', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='審核步驟表';
3. ?? ??? ??
???? ?? ???? ????, ???? ???? ?? ???? ??? ????, ??? ?? ??? ???? ???.
???? ?? ??? ??- ?? ???? ?? ???? FlowModel? ????, ?? ?? ???? StepModel? ??? ??? ????, ???? ?? ?? ???? ?????.
// ppmodelFlowModel.php namespace appmodel; use thinkModel; class FlowModel extends Model { protected $table = 'tp_flow'; // 定義與StepModel的一對(duì)多關(guān)系 public function steps() { return $this->hasMany('StepModel', 'flow_id', 'id'); } // 創(chuàng)建審核流程 public function addFlow($data) { return $this->save($data); } // 編輯審核流程 public function editFlow($id, $data) { return $this->where('id', $id)->update($data); } // 刪除審核流程 public function delFlow($id) { return $this->where('id', $id)->delete(); } // 按照ID獲取審核流程詳情 public function getFlowById($id) { return $this->with('steps')->find($id); } // 獲取審核流程列表 public function getFlowList() { return $this->with('steps')->select(); } }
2. ?? ?? ???? ?????
?? ?? ?? ?? ??? StepModel? ???? ???? ?? ??? FlowModel?? ?? ??? ???? ?? ??? ??? ???? ?????.
// ppmodelStepModel.php namespace appmodel; use thinkModel; class StepModel extends Model { protected $table = 'tp_step'; // 定義與FlowModel的屬于關(guān)系 public function flow() { return $this->belongsTo('FlowModel', 'flow_id'); } // 添加審核步驟 public function addStep($data) { return $this->save($data); } // 編輯審核步驟 public function editStep($id, $data) { return $this->where('id', $id)->update($data); } // 刪除審核步驟 public function delStep($id) { return $this->where('id', $id)->delete(); } // 按照ID獲取審核步驟詳情 public function getStepById($id) { return $this->find($id); } // 獲取審核步驟列表 public function getStepListByFlowId($flow_id) { return $this->where('flow_id', $flow_id)->select(); } // 更新審核步驟狀態(tài) public function updateStepStatus($id, $status, $handler_id, $handle_time) { $data = [ 'status' => $status, 'handler_id' => $handler_id, 'handle_time' => $handle_time, ]; return $this->where('id', $id)->update($data); } }
3. ?? ???? ??
?? ???? ????? ?? ????? ? ??? ???? ?? ???? ?? ??? ???? ???? ? ?? ?? ???? ???? ???? ???.
?? ???? ???- ???? ??????? ?? ????? ?? ? ?? ????? ?? ?? ??? ???? ???.
// ppcontrollerFlowController.php namespace appcontroller; use appBaseController; use appmodelFlowModel; use appmodelStepModel; use thinkRequest; class FlowController extends BaseController { protected $flowModel; protected $stepModel; public function __construct(FlowModel $flowModel, StepModel $stepModel) { $this->flowModel = $flowModel; $this->stepModel = $stepModel; } // 創(chuàng)建審核流程 public function addFlow(Request $request) { $data = $request->post(); // 添加審核流程 $flow_result = $this->flowModel->addFlow([ 'name' => $data['name'], 'create_user_id' => $this->getCurrentUserId(), 'create_time' => date('Y-m-d H:i:s'), ]); if (!$flow_result) { return $this->error('創(chuàng)建審核流程失敗!'); } // 添加審核步驟 $step_data = []; foreach ($data['step'] as $key => $value) { $step_data[] = [ 'flow_id' => $this->flowModel->id, 'name' => $value['name'], 'handler_id' => $value['handler_id'], ]; } $step_result = $this->stepModel->saveAll($step_data); if (!$step_result) { return $this->error('添加審核步驟失??!'); } return $this->success('創(chuàng)建審核流程成功!'); } }??? ?? ??
- ?? ???? ??? ? ???? ???? ?? ????? ???? ?? ????? ????? ?? ???.
// ppcontrollerApplyController.php namespace appcontroller; use appBaseController; use appmodelStepModel; use thinkRequest; class ApplyController extends BaseController { protected $stepModel; public function __construct(StepModel $stepModel) { $this->stepModel = $stepModel; } // 提交審核 public function submitApply(Request $request) { $data = $request->post(); // 獲取審核流程的第一步驟 $steps = $this->stepModel->getStepListByFlowId($data['flow_id']); if (empty($steps)) { return $this->error('該審核流程未添加步驟!'); } $first_step = $steps[0]; // 更新第一步驟狀態(tài) $update_result = $this->stepModel->updateStepStatus($first_step->id, 1, $this->getCurrentUserId(), date('Y-m-d H:i:s')); if (!$update_result) { return $this->error('更新審核步驟狀態(tài)失?。?); } return $this->success('提交審核成功!'); } }?? ????? ?? ??
- ???? ?? ????? ??? ??? ?? ??? ??? ???? ???? ???? ?? ??? ?????.
// ppcontrollerApproveController.php namespace appcontroller; use appBaseController; use appmodelStepModel; use thinkRequest; class ApproveController extends BaseController { protected $stepModel; public function __construct(StepModel $stepModel) { $this->stepModel = $stepModel; } // 審核步驟 public function approveStep(Request $request) { $data = $request->post(); // 獲取當(dāng)前步驟 $step = $this->stepModel->getStepById($data['step_id']); // 更新當(dāng)前步驟狀態(tài) $update_result = $this->stepModel->updateStepStatus($data['step_id'], $data['status'], $this->getCurrentUserId(), date('Y-m-d H:i:s')); if (!$update_result) { return $this->error('更新審核步驟狀態(tài)失??!'); } // 獲取下一步驟 $next_step = $this->stepModel->where('flow_id', $step->flow_id)->where('id', '>', $data['step_id'])->order('id asc')->find(); if (!$next_step) { return $this->success('已審核完成!'); } // 更新下一步驟狀態(tài) $update_result = $this->stepModel->updateStepStatus($next_step->id, 1, $next_step->handler_id, null); if (!$update_result) { return $this->error('更新審核步驟狀態(tài)失??!'); } return $this->success('審核通過(guò)!'); } }
IV. ??
?? ?? ??? ?? ThinkPHP6??? ???? ???? ?? ???? ?? ??, ?? ???? ??? ??? ?? ?? ???? ?? ??? ?? ???? ???? ??? ? ? ????. ??? ?? ???? ?? ???? ??? ???? ??? ? ????.
? ??? ThinkPHP6?? ?? ????? ???? ??? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

ThinkPHP ????? ????? ??? ?????: Composer? ????, ???? ????? ???? php bin/console? ????, ?? ???? ??? http://localhost:8000? ?????.

ThinkPHP?? ??? PHP ????? ??? ?? ??? ????. ??? ???? 3.2, 5.0, 5.1, 6.0? ????, ??? ??? ??? ???? ??? ??? ???? ? ?????. ?? ?? ??? ThinkPHP 6.0.16???. ??? ??? ? PHP ??, ?? ?? ?? ? ???? ??? ??????. ??? ??? ??? ???? ?? ?? ??? ???? ?? ????.

ThinkPHP Framework? ???? ???? ??: ThinkPHP Framework? ?? ????? ?????? ??? ???. ThinkPHP ?? ????? ???? ?? ???(?? ??)? ????. ?????? ?? ????? ?????. ? ??? ?????. ThinkPHP ??????? ??????. ThinkPHP ?????? URL? ???? ?????.

Laravel? ThinkPHP ?????? ?? ??: ThinkPHP? ????? ??? ? ??? ??? ?? Laravel?? ??? ????. Laravel? ? ????? ??? ??????? ?? ThinkPHP? ? ??? ? ????.

ThinkPHP ?? ??: PHP, Composer ? MySQL ??? ?????. Composer? ???? ????? ????. ThinkPHP ?????? ???? ?????. ?????? ??? ?????. ?????? ??? ?????. ??????? ???? http://localhost:8000? ?????.

ThinkPHP? ?? ????, ?? ???, ?? ?? ? ?????? ???? ?? ??? ?? ??? PHP ????????. ?? ?? ???? ??? ?? 10,000? ??? ??? ??? ? ??? JD.com, Ctrip? ?? ??? ? ??? ? ?????? ????? ?? ?? ?????? ?? ?????.

ThinkPHP ????? ????? ??? ???? ???. 1. ?? ????? ????. 2. ??????? ?????. 4. ?????? ??? ???? ??? ?????. 7. ????? ?????. ?? ???? ??? ?? ??, ???? ?? ??? ? ???? ??? ?????.

Oracle ???????? ??? ????? ??? ?? ??? ?????. Oracle ???????? ??? ????(MasterDirectory)? ?? ??? ?? ??? ??? ?? ??? ?? ?? ??? ?????? ????. ??? ??????. ? ????? ???? ?????? ??? ?? ? ???? ?? ???? ??????? ??? ??? ???? ? ????. ? ????? ??? ?? ???? ??? ? ????. 1. ? ???? ?? ? ????? ????? ??? ?????.
