diff --git a/application/common/model/Attachment.php b/application/common/model/Attachment.php index 79878c6..2149aec 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; + } + }); + } }