add plugin show page
This commit is contained in:
parent
77f28a598e
commit
5671f2d2bf
|
|
@ -37,6 +37,20 @@ class MarketingController
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取单个插件详情
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
$code = $request->code;
|
||||
$plugin = MarketingService::getPlugin($code);
|
||||
$data = [
|
||||
'plugin' => $plugin,
|
||||
];
|
||||
return view('admin::pages.marketing.show', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下载插件安装包到本地
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ Route::prefix($adminName)
|
|||
|
||||
// 插件市场
|
||||
Route::middleware('can:marketing_index')->get('marketing', [Controllers\MarketingController::class, 'index'])->name('marketing.index');
|
||||
Route::middleware('can:marketing_show')->get('marketing/{code}', [Controllers\MarketingController::class, 'show'])->name('marketing.show');
|
||||
Route::middleware('can:marketing_download')->get('marketing/{code}/download', [Controllers\MarketingController::class, 'download'])->name('marketing.download');
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,4 +20,10 @@ class MarketingService
|
|||
$url = config('beike.api_url') . '/api/plugins';
|
||||
return Http::get($url)->json();
|
||||
}
|
||||
|
||||
public static function getPlugin($code)
|
||||
{
|
||||
$url = config('beike.api_url') . '/api/plugins/' . $code;
|
||||
return Http::get($url)->json();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* bootstrap.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author Edward Yang <yangjin@opencart.cn>
|
||||
* @created 2022-07-20 15:35:59
|
||||
* @modified 2022-07-20 15:35:59
|
||||
*/
|
||||
|
||||
namespace Plugin\HeaderMenu;
|
||||
|
||||
class Bootstrap
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
add_filter('header.categories', function ($data) {
|
||||
$data[] = [
|
||||
'name' => '插件链接',
|
||||
'url' => shop_route('home.index'),
|
||||
'children' => [
|
||||
[
|
||||
"name" => "最新商品",
|
||||
"url" => plugin_route('latest_products'),
|
||||
], [
|
||||
"name" => "百度",
|
||||
"url" => "https://www.baidu.com",
|
||||
]
|
||||
],
|
||||
];
|
||||
return $data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* MenusController.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author Edward Yang <yangjin@opencart.cn>
|
||||
* @created 2022-07-21 10:00:25
|
||||
* @modified 2022-07-21 10:00:25
|
||||
*/
|
||||
|
||||
namespace Plugin\HeaderMenu\Controllers;
|
||||
|
||||
use Beike\Repositories\ProductRepo;
|
||||
use Beike\Shop\Http\Controllers\Controller;
|
||||
|
||||
class MenusController extends Controller
|
||||
{
|
||||
public function latestProducts()
|
||||
{
|
||||
$products = ProductRepo::getBuilder()->orderByDesc('updated_at')->paginate(40);
|
||||
return view("HeaderMenu::latest_products", ['products' => $products]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
@extends('layout.master')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<div class="row">
|
||||
@foreach ($products as $product)
|
||||
<div class="col-6 col-md-3">@include('shared.product')</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
{{ $products->links('shared/pagination/bootstrap-4') }}
|
||||
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"code": "header_menu",
|
||||
"name": "首页菜单Demo",
|
||||
"description": "修改首页菜单插件",
|
||||
"type": "view",
|
||||
"version": "v1.0.0",
|
||||
"icon": "https://via.placeholder.com/100x100.png/aabbcc?text=MENU",
|
||||
"author": {
|
||||
"name": "成都光大网络科技有限公司",
|
||||
"email": "yangjin@opencart.cn"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* route.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author Edward Yang <yangjin@opencart.cn>
|
||||
* @created 2022-07-21 09:35:05
|
||||
* @modified 2022-07-21 09:35:05
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/latest_products', '\Plugin\HeaderMenu\Controllers\MenusController@latestProducts')->name('plugin.latest_products');
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title', __('admin/marketing.marketing_list'))
|
||||
|
||||
@section('content')
|
||||
@dump($plugin)
|
||||
@endsection
|
||||
|
||||
@push('footer')
|
||||
<script>
|
||||
</script>
|
||||
@endpush
|
||||
Loading…
Reference in New Issue