From 89ff31c74942550d8ecfe4fde81eca38042e1310 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Jul 2024 17:25:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=20=E5=88=86=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common.php | 2 +- app/controller/ShareController.php | 25 +++++++++++++++++++++++++ app/model/Content.php | 9 +++++++++ app/model/ShareItem.php | 10 ++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 app/controller/ShareController.php create mode 100644 app/model/Content.php diff --git a/app/common.php b/app/common.php index fa1293d..f3ee1c8 100644 --- a/app/common.php +++ b/app/common.php @@ -60,7 +60,7 @@ function findParent($obj, $id, &$path) function getResourceShareInfo() { $code = uniqid(); - $share_link = url('share/index', ['id' => $code])->domain(true); + $share_link = url('share/index', ['code' => $code])->domain(true); $password = str_pad(rand(0, 9999), 4, '0', STR_PAD_LEFT); return [ 'code' => $code, diff --git a/app/controller/ShareController.php b/app/controller/ShareController.php new file mode 100644 index 0000000..5c8d7e8 --- /dev/null +++ b/app/controller/ShareController.php @@ -0,0 +1,25 @@ +param('code'); + + $share = Share::with(['share_item', 'share_item.target']) + ->where('code', $code)->find(); + return jsonReturn(0, Lang::get('成功'), $share); + } +} diff --git a/app/model/Content.php b/app/model/Content.php new file mode 100644 index 0000000..0663d83 --- /dev/null +++ b/app/model/Content.php @@ -0,0 +1,9 @@ +morphTo('target', [ + '1' => Resource::class, + '2' => Content::class, + ]); + } }