From 7a3fa9d6c1dd53bc511977441136819bd797e51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=B0=E5=A4=A7=E7=8B=BC?= Date: Sun, 3 Mar 2019 16:06:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9Attachment=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=90=8C=E5=90=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=94=9F=E6=88=90=E8=AE=B0=E5=BD=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/model/Attachment.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/application/common/model/Attachment.php b/application/common/model/Attachment.php index 79878c6d..2149aec7 100644 --- a/application/common/model/Attachment.php +++ b/application/common/model/Attachment.php @@ -21,4 +21,13 @@ class Attachment extends Model return strtotime($value); } + protected static function init() + { + // 如果已经上传该资源,则不再记录 + self::beforeInsert(function ($model) { + if (self::where('url', '=', $model['url'])->find()) { + return false; + } + }); + } }