first commit
This commit is contained in:
84
modules/Ads/app/Controllers/Admin/Ads.php
Normal file
84
modules/Ads/app/Controllers/Admin/Ads.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace Modules\Ads\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\BaseController;
|
||||
use Modules\Ads\Services\AdsService;
|
||||
|
||||
class Ads extends BaseController {
|
||||
|
||||
/**
|
||||
* @title 广告列表
|
||||
*
|
||||
* @param Request $request
|
||||
* @param AdsService $service
|
||||
* @return void
|
||||
*/
|
||||
public function index(Request $request, AdsService $service) {
|
||||
try {
|
||||
$this->data['data'] = $service->getDataList($request);
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加广告
|
||||
*
|
||||
* @param Request $request
|
||||
* @param AdsService $service
|
||||
* @return void
|
||||
*/
|
||||
public function add(Request $request, AdsService $service) {
|
||||
try {
|
||||
$this->data['data'] = $service->create($request);
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑广告
|
||||
*
|
||||
* @param Request $request
|
||||
* @param AdsService $service
|
||||
* @return void
|
||||
*/
|
||||
public function edit(Request $request, AdsService $service) {
|
||||
try {
|
||||
$this->data['data'] = $service->update($request);
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除广告
|
||||
*
|
||||
* @param Request $request
|
||||
* @param AdsService $service
|
||||
* @return void
|
||||
*/
|
||||
public function delete(Request $request, AdsService $service) {
|
||||
try {
|
||||
$this->data['data'] = $service->delete($request);
|
||||
} catch (\Exception $e) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $e->getMessage();
|
||||
}
|
||||
return response()->json($this->data);
|
||||
}
|
||||
}
|
||||
35
modules/Ads/app/Controllers/Api/Ads.php
Normal file
35
modules/Ads/app/Controllers/Api/Ads.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace Modules\Ads\Controllers\Api;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\BaseController;
|
||||
use Modules\Ads\Services\AdsService;
|
||||
|
||||
class Ads extends BaseController {
|
||||
|
||||
/**
|
||||
* @title 广告列表
|
||||
*
|
||||
* @param Request $request
|
||||
* @param AdsService $service
|
||||
* @return void
|
||||
*/
|
||||
public function index(Request $request, AdsService $service){
|
||||
try {
|
||||
$request->mergeIfMissing(['status' => 1]);
|
||||
$this->data['data'] = $service->getDataList($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
}
|
||||
28
modules/Ads/app/Models/Ads.php
Normal file
28
modules/Ads/app/Models/Ads.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace Modules\Ads\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class Ads extends BaseModel {
|
||||
|
||||
protected $table = 'ads';
|
||||
protected $fillable = ['title', 'description', 'logo', 'sort','status'];
|
||||
// protected $hidden = ['deleted_at'];
|
||||
|
||||
protected function casts(): array {
|
||||
return [
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
'created_at' => 'datetime:Y-m-d H:i:s',
|
||||
'updated_at' => 'datetime:Y-m-d H:i:s',
|
||||
];
|
||||
}
|
||||
}
|
||||
0
modules/Ads/app/Providers/.gitkeep
Normal file
0
modules/Ads/app/Providers/.gitkeep
Normal file
120
modules/Ads/app/Providers/AdsServiceProvider.php
Normal file
120
modules/Ads/app/Providers/AdsServiceProvider.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Ads\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AdsServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Ads';
|
||||
|
||||
protected string $moduleNameLower = 'ads';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(EventServiceProvider::class);
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', '')));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
38
modules/Ads/app/Providers/EventServiceProvider.php
Normal file
38
modules/Ads/app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace Modules\Ads\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array<string, array<int, string>>
|
||||
*/
|
||||
protected $listen = [];
|
||||
|
||||
/**
|
||||
* Indicates if events should be discovered.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $shouldDiscoverEvents = true;
|
||||
|
||||
/**
|
||||
* Configure the proper event listeners for email verification.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureEmailVerification(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
67
modules/Ads/app/Providers/RouteServiceProvider.php
Normal file
67
modules/Ads/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace Modules\Ads\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
|
||||
$this->mapAdminRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')->group(module_path('Ads', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Ads', '/routes/api.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapAdminRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('admin')->name('admin.')->group(module_path('Ads', '/routes/admin.php'));
|
||||
}
|
||||
}
|
||||
124
modules/Ads/app/Services/AdsService.php
Normal file
124
modules/Ads/app/Services/AdsService.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace Modules\Ads\Services;
|
||||
|
||||
use Modules\Ads\Models\Ads;
|
||||
|
||||
class AdsService {
|
||||
|
||||
/**
|
||||
* @title 广告列表
|
||||
*
|
||||
* @param [type] $request
|
||||
* @return void
|
||||
*/
|
||||
public function getDataList($request){
|
||||
$map = [];
|
||||
|
||||
if($request->filled('title')){
|
||||
$map[] = ['title', 'like', '%'.$request->input('title').'%'];
|
||||
}
|
||||
if($request->filled('client_id')){
|
||||
$map[] = ['client_id', '=', $request->input('client_id')];
|
||||
}
|
||||
if($request->filled('code')){
|
||||
$map[] = ['code', '=', $request->input('code')];
|
||||
}
|
||||
if($request->filled('group')){
|
||||
$map[] = ['group', '=', $request->input('group')];
|
||||
}
|
||||
if($request->filled('status')){
|
||||
$map[] = ['status', '=', $request->input('status')];
|
||||
}
|
||||
|
||||
$query = Ads::where($map);
|
||||
|
||||
$query->orderBy($request->input('order', 'sort'), $request->input('sort', 'desc'));
|
||||
if($request->filled('page')){
|
||||
$data = [
|
||||
'total' => $query->count(),
|
||||
'page' => $request->input('page', 1),
|
||||
'data' => $query->offset($request->input('offset', 0))->limit($request->input('limit', 10))->get(),
|
||||
];
|
||||
}else{
|
||||
$data = $query->get();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加广告
|
||||
*
|
||||
* @param [type] $request
|
||||
* @return void
|
||||
*/
|
||||
public function create($request){
|
||||
$request->validate([
|
||||
'title' => 'required',
|
||||
'group' => 'required'
|
||||
], [
|
||||
'title.required' => '请输入广告名称',
|
||||
'group.required' => '请输入广告位标识'
|
||||
]);
|
||||
|
||||
$ads = new Ads;
|
||||
foreach ($ads->setFilterFields($request->all()) as $key => $value) {
|
||||
$ads->$key = $value;
|
||||
}
|
||||
|
||||
$ads->save();
|
||||
return $ads;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 更新广告
|
||||
*
|
||||
* @param [type] $request
|
||||
* @return void
|
||||
*/
|
||||
public function update($request){
|
||||
$request->validate([
|
||||
'title' => 'required',
|
||||
'group' => 'required'
|
||||
], [
|
||||
'title.required' => '请输入广告名称',
|
||||
'group.required' => '请输入广告位标识'
|
||||
]);
|
||||
|
||||
$ads = Ads::findOrFail($request->input('id'));
|
||||
|
||||
foreach ($ads->setFilterFields($request->all()) as $key => $value) {
|
||||
$ads->$key = $value;
|
||||
}
|
||||
|
||||
$ads->save();
|
||||
return $ads;
|
||||
}
|
||||
|
||||
public function delete($request){
|
||||
if($request->filled('id')){
|
||||
try {
|
||||
$ads = Ads::findOrFail($request->input('id'));
|
||||
} catch (\Throwable $th) {
|
||||
throw new \Exception("广告不存在!", 1);
|
||||
}
|
||||
$ads->delete();
|
||||
}
|
||||
if($request->filled('ids')){
|
||||
try {
|
||||
$ads = Ads::whereIn('id', $request->input('ids'));
|
||||
$ads->delete();
|
||||
} catch (\Throwable $th) {
|
||||
throw new \Exception($th->getMessage(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $ads;
|
||||
}
|
||||
}
|
||||
30
modules/Ads/composer.json
Normal file
30
modules/Ads/composer.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "tensent/ads",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "molong",
|
||||
"email": "molong@tensent.cn"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Ads\\": "app/",
|
||||
"Modules\\Ads\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\Ads\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Ads\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
0
modules/Ads/config/.gitkeep
Normal file
0
modules/Ads/config/.gitkeep
Normal file
5
modules/Ads/config/config.php
Normal file
5
modules/Ads/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Ads',
|
||||
];
|
||||
0
modules/Ads/database/factories/.gitkeep
Normal file
0
modules/Ads/database/factories/.gitkeep
Normal file
0
modules/Ads/database/migrations/.gitkeep
Normal file
0
modules/Ads/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void {
|
||||
Schema::create('ads', function (Blueprint $table) {
|
||||
$table->id()->uniqid()->comment('主键id');
|
||||
$table->unsignedBigInteger('client_id')->default(0)->comment('站点ID');
|
||||
$table->string('title')->comment('广告标题');
|
||||
$table->string('name')->nullable()->comment('广告标识');
|
||||
$table->string('group')->nullable()->comment('广告所属板块标识');
|
||||
$table->string('description')->nullable()->comment('广告描述');
|
||||
$table->string('cover')->nullable()->comment('广告封面');
|
||||
$table->string('link')->nullable()->comment('广告链接');
|
||||
$table->string('sort')->default(0)->comment('排序');
|
||||
$table->tinyInteger('status')->default(1)->comment('状态 1正常 2禁用');
|
||||
$table->timestamp('created_at')->nullable()->comment('创建时间');
|
||||
$table->timestamp('updated_at')->nullable()->comment('更新时间');
|
||||
|
||||
$table->engine = 'InnoDB';
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_unicode_ci';
|
||||
$table->comment('广告表');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('ads');
|
||||
}
|
||||
};
|
||||
0
modules/Ads/database/seeders/.gitkeep
Normal file
0
modules/Ads/database/seeders/.gitkeep
Normal file
42
modules/Ads/database/seeders/AdsDatabaseSeeder.php
Normal file
42
modules/Ads/database/seeders/AdsDatabaseSeeder.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace Modules\Ads\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Services\Auth\MenuService;
|
||||
|
||||
class AdsDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->initMenu();
|
||||
}
|
||||
|
||||
public function initMenu(){
|
||||
$menuService = app(MenuService::class);
|
||||
|
||||
$operate = DB::table('auth_permissions')->where('name', 'operate')->first();
|
||||
if (!$operate) {
|
||||
$menu = [
|
||||
['title' => '营销', 'name' => 'operate', 'path' => '/operate', 'component' => '', 'type' => 'menu', 'sort' => 5, 'children' => [
|
||||
['title' => '广告管理', 'name' => 'operate.ads', 'path' => '/operate/ads', 'component' => 'operate/ads', 'type' => 'menu']
|
||||
]]
|
||||
];
|
||||
$menuService->importMenu($menu, 0);
|
||||
}else{
|
||||
$menuService->importMenu([
|
||||
['title' => '广告管理', 'name' => 'operate.ads', 'path' => '/operate/ads', 'component' => 'operate/ads', 'type' => 'menu']
|
||||
], $operate->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
modules/Ads/module.json
Normal file
11
modules/Ads/module.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Ads",
|
||||
"alias": "ads",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Ads\\Providers\\AdsServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
||||
15
modules/Ads/package.json
Normal file
15
modules/Ads/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.1.2",
|
||||
"laravel-vite-plugin": "^0.7.5",
|
||||
"sass": "^1.69.5",
|
||||
"postcss": "^8.3.7",
|
||||
"vite": "^4.0.0"
|
||||
}
|
||||
}
|
||||
0
modules/Ads/resources/assets/js/app.js
Normal file
0
modules/Ads/resources/assets/js/app.js
Normal file
0
modules/Ads/resources/assets/sass/app.scss
Normal file
0
modules/Ads/resources/assets/sass/app.scss
Normal file
7
modules/Ads/resources/views/index.blade.php
Normal file
7
modules/Ads/resources/views/index.blade.php
Normal file
@@ -0,0 +1,7 @@
|
||||
@extends('ads::layouts.master')
|
||||
|
||||
@section('content')
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>Module: {!! config('ads.name') !!}</p>
|
||||
@endsection
|
||||
29
modules/Ads/resources/views/layouts/master.blade.php
Normal file
29
modules/Ads/resources/views/layouts/master.blade.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>Ads Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-ads', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-ads', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
||||
0
modules/Ads/routes/.gitkeep
Normal file
0
modules/Ads/routes/.gitkeep
Normal file
16
modules/Ads/routes/admin.php
Normal file
16
modules/Ads/routes/admin.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::controller(Modules\Ads\Controllers\Admin\Ads::class)->prefix('ads')->name('ads.')->group(function () {
|
||||
Route::get('/index', 'index')->name('index');
|
||||
Route::post('/add', 'add')->name('add');
|
||||
Route::put('/edit', 'edit')->name('edit');
|
||||
Route::delete('/delete', 'delete')->name('delete');
|
||||
});
|
||||
13
modules/Ads/routes/api.php
Normal file
13
modules/Ads/routes/api.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::controller(Modules\Ads\Controllers\Api\Ads::class)->prefix('ads')->name('ads.')->group(function () {
|
||||
Route::get('/index', 'index')->name('index');
|
||||
});
|
||||
9
modules/Ads/routes/web.php
Normal file
9
modules/Ads/routes/web.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
use Illuminate\Support\Facades\Route;
|
||||
26
modules/Ads/vite.config.js
Normal file
26
modules/Ads/vite.config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: '../../public/build-ads',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-ads',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/Ads/resources/assets/sass/app.scss',
|
||||
// 'Modules/Ads/resources/assets/js/app.js',
|
||||
//];
|
||||
Reference in New Issue
Block a user