下载远程链接

This commit is contained in:
Edward Yang 2022-09-26 14:55:30 +08:00
parent f3a664f8ca
commit 48837d4e04
2 changed files with 25 additions and 0 deletions

View File

@ -12,10 +12,15 @@
namespace Beike\Admin\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Beike\Admin\Services\MarketingService;
class MarketingController
{
/**
* @param Request $request
* @return mixed
*/
public function index(Request $request)
{
$plugins = MarketingService::getList();
@ -24,4 +29,22 @@ class MarketingController
];
return view('admin::pages.marketing.index', $data);
}
/**
* 下载插件安装包到本地
*/
public function download(Request $request)
{
$pluginCode = $request->code;
$datetime = date('Y-m-d');
$url = config('beike.api_url') . "/api/plugins/{$pluginCode}/download";
$content = file_get_contents($url);
$pluginPath = "plugins/{$pluginCode}-{$datetime}.zip";
Storage::disk('local')->put($pluginPath, $content);
$pluginZip = storage_path('app' . $pluginPath);
dd($pluginZip);
}
}

View File

@ -142,6 +142,8 @@ Route::prefix($adminName)
// 插件市场
Route::middleware('can:marketing_index')->get('marketing', [Controllers\MarketingController::class, 'index'])->name('marketing.index');
Route::middleware('can:marketing_download')->get('marketing/{code}/download', [Controllers\MarketingController::class, 'download'])->name('marketing.download');
// 单页
Route::middleware('can:pages_index')->get('pages', [Controllers\PagesController::class, 'index'])->name('pages.index');