新增附件事件

This commit is contained in:
JaguarJack 2020-06-01 21:25:46 +08:00
parent 39c0ec4c48
commit fe6ea82014
3 changed files with 67 additions and 36 deletions

View File

@ -0,0 +1,17 @@
<?php
namespace catchAdmin\system\events;
use catchAdmin\system\model\Attachments;
class AttachmentEvent
{
public function handle($params)
{
$file = $params['file'];
unset($params['file']);
Attachments::store($params, $file);
}
}

View File

@ -89,6 +89,10 @@ return [
'operateLog' => [
OperateLogEvent::class,
],
// 附件操作
'attachment' => [
\catchAdmin\system\events\AttachmentEvent::class,
],
// 路由加载
'RouteLoaded' => [
LoadModuleRoutes::class

View File

@ -63,10 +63,12 @@ class CatchUpload
if ($path) {
$url = self::getCloudDomain($this->getDriver()) . $path;
Attachments::create(array_merge([
event('attachment', [
'path' => $path,
'url' => $url,
], $this->data($file)));
'driver' => $this->getDriver(),
'file' => $file,
]);
return $url;
}
@ -215,7 +217,12 @@ class CatchUpload
return $this;
}
/**
* 初始化配置
*
* @time 2020年06月01日
* @return void
*/
protected function initUploadConfig()
{
$configModel = app(Config::class);
@ -224,7 +231,9 @@ class CatchUpload
if ($upload) {
$disk = app()->config->get('filesystem.disks');
$uploadConfigs = $configModel->getConfig($upload->id);
if (!empty($uploadConfigs)) {
// 读取上传可配置数据
foreach ($uploadConfigs as $key => &$config) {
// $disk[$key]['type'] = $key;
@ -261,6 +270,7 @@ class CatchUpload
], 'filesystem');
}
}
}
/**
* 获取云存储的域名