mirror of https://gitee.com/karson/fastadmin.git
修改Attachment模型,防止同名文件重复生成记录。
parent
d5bdcd1cd6
commit
7a3fa9d6c1
|
|
@ -21,4 +21,13 @@ class Attachment extends Model
|
||||||
return strtotime($value);
|
return strtotime($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
// 如果已经上传该资源,则不再记录
|
||||||
|
self::beforeInsert(function ($model) {
|
||||||
|
if (self::where('url', '=', $model['url'])->find()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue