正在显示
1 个修改的文件
包含
9 行增加
和
0 行删除
@@ -21,4 +21,13 @@ class Attachment extends Model | @@ -21,4 +21,13 @@ class Attachment extends Model | ||
21 | return strtotime($value); | 21 | return strtotime($value); |
22 | } | 22 | } |
23 | 23 | ||
24 | + protected static function init() | ||
25 | + { | ||
26 | + // 如果已经上传该资源,则不再记录 | ||
27 | + self::beforeInsert(function ($model) { | ||
28 | + if (self::where('url', '=', $model['url'])->find()) { | ||
29 | + return false; | ||
30 | + } | ||
31 | + }); | ||
32 | + } | ||
24 | } | 33 | } |
-
请 注册 或 登录 后发表评论