diff --git a/beike/Admin/Http/Controllers/MarketingController.php b/beike/Admin/Http/Controllers/MarketingController.php index 0ee820a1..97f1cad4 100644 --- a/beike/Admin/Http/Controllers/MarketingController.php +++ b/beike/Admin/Http/Controllers/MarketingController.php @@ -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); + } } diff --git a/beike/Admin/Routes/admin.php b/beike/Admin/Routes/admin.php index 7cf572ed..b3f26a03 100644 --- a/beike/Admin/Routes/admin.php +++ b/beike/Admin/Routes/admin.php @@ -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');