diff --git a/app/Admin/Controllers/ArticleController.php b/app/Admin/Controllers/ArticleController.php index ad0a84f..bc5d6d7 100644 --- a/app/Admin/Controllers/ArticleController.php +++ b/app/Admin/Controllers/ArticleController.php @@ -40,7 +40,7 @@ class ArticleController extends AdminController return $this->baseForm()->body([ TextControl::make()->name('title')->label('标题')->required(true), TextControl::make()->name('sub_title')->label('副标题'), - amisMake()->ImageControl()->name('cover')->label('封面')->autoUpload(true), + \amisMake()->ImageControl()->name('cover')->label('封面')->autoUpload(true), Components::make()->parentControl('', 'category_id', '分类'), Components::make()->fuEditorControl(), Components::make()->sortControl(), diff --git a/app/Admin/Controllers/BannerController.php b/app/Admin/Controllers/BannerController.php new file mode 100644 index 0000000..ac5b863 --- /dev/null +++ b/app/Admin/Controllers/BannerController.php @@ -0,0 +1,59 @@ +baseCRUD() + ->filterTogglable(false) + ->headerToolbar([ + $this->createButton(true), + ...$this->baseHeaderToolBar(), + ]) + ->columns([ + TableColumn::make()->name('id')->label('ID')->sortable(true), + TableColumn::make()->name('name')->label('名称'), + TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true), + TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true), + $this->rowActions(true), + ]); + + return $this->baseList($crud); + } + + public function form(): Form + { + return $this->baseForm()->body([ + TextControl::make()->name('name')->label('名称')->required(true), + \amisMake()->ImageControl()->name('picture')->label('图片')->autoUpload(true), + Components::make()->parentControl('', 'place_id', '位置'), + Components::make()->sortControl(), + \amisMake()->DateTimeControl()->name('published_at')->label('发布时间')->description('*不填写则默认为创建时间'), + \amisMake()->SwitchControl()->name('is_enable')->label('显示'), + ]); + } + + public function detail(): Form + { + return $this->baseDetail()->body([ + TextControl::make()->static(true)->name('id')->label('ID'), + TextControl::make()->static(true)->name('name')->label('名称'), + TextControl::make()->static(true)->name('created_at')->label('创建时间'), + TextControl::make()->static(true)->name('updated_at')->label('更新时间') + ]); + } +} diff --git a/app/Admin/Controllers/BannerPlaceController.php b/app/Admin/Controllers/BannerPlaceController.php new file mode 100644 index 0000000..35340e1 --- /dev/null +++ b/app/Admin/Controllers/BannerPlaceController.php @@ -0,0 +1,56 @@ +baseCRUD() + ->filterTogglable(false) + ->headerToolbar([ + $this->createButton(true), + ...$this->baseHeaderToolBar(), + ]) + ->columns([ + TableColumn::make()->name('id')->label('ID')->sortable(true), + TableColumn::make()->name('name')->label('名称'), + TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true), + TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true), + $this->rowActions(true), + ]); + + return $this->baseList($crud); + } + + public function form(): Form + { + return $this->baseForm()->body([ + TextControl::make()->name('name')->label('名称')->required(true), + TextControl::make()->name('key')->label('KEY')->required(true), + \amisMake()->SwitchControl()->name('is_enable')->label('显示'), + TextControl::make()->name('remark')->label('备注'), + ]); + } + + public function detail(): Form + { + return $this->baseDetail()->body([ + TextControl::make()->static(true)->name('id')->label('ID'), + TextControl::make()->static(true)->name('name')->label('名称'), + TextControl::make()->static(true)->name('created_at')->label('创建时间'), + TextControl::make()->static(true)->name('updated_at')->label('更新时间') + ]); + } +} diff --git a/app/Admin/routes.php b/app/Admin/routes.php index 3314fff..d365965 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -22,6 +22,10 @@ Route::group([ $router->resource('article-categories', \App\Admin\Controllers\ArticleCategoryController::class); //文章管理 $router->resource('articles', \App\Admin\Controllers\ArticleController::class); + //图片位置 + $router->resource('banner-places', \App\Admin\Controllers\BannerPlaceController::class); + //图片管理 + $router->resource('banners', \App\Admin\Controllers\BannerController::class); $router->resource('keywords', \App\Admin\Controllers\KeywordController::class); diff --git a/app/Models/Banner.php b/app/Models/Banner.php new file mode 100644 index 0000000..f007d2b --- /dev/null +++ b/app/Models/Banner.php @@ -0,0 +1,11 @@ +id(); + $table->string('name'); + $table->string('key'); + $table->unsignedInteger('height')->nullable()->comment('高:px'); + $table->unsignedInteger('width')->nullable()->comment('宽:px'); + $table->string('remark')->nullable()->comment('备注'); + $table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('banner_places'); + } +}; diff --git a/database/migrations/2023_03_20_153825_create_banners_table.php b/database/migrations/2023_03_20_153825_create_banners_table.php new file mode 100644 index 0000000..77f3cfd --- /dev/null +++ b/database/migrations/2023_03_20_153825_create_banners_table.php @@ -0,0 +1,38 @@ +id(); + $table->string('name'); + $table->string('picture'); + $table->unsignedBigInteger('place_id')->nullable()->comment('位置'); + $table->timestamp('published_at')->nullable()->comment('发布时间'); + $table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关'); + $table->unsignedInteger('sort')->default(0)->comment('排序'); + $table->text('link_config')->nullable()->comment('跳转配置'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('banners'); + } +}; diff --git a/database/seeders/AdminMenuSeeder.php b/database/seeders/AdminMenuSeeder.php index 887611e..8d62f48 100644 --- a/database/seeders/AdminMenuSeeder.php +++ b/database/seeders/AdminMenuSeeder.php @@ -25,7 +25,7 @@ class AdminMenuSeeder extends Seeder ['title' => '公告管理', 'icon' => 'icon-park:volume-notice', 'url' => '/admin-notices'], ['title' => '文章分类', 'icon' => 'icon-park:book-one', 'url' => '/article-categories'], ['title' => '文章管理', 'icon' => 'icon-park:file-search', 'url' => '/articles'], - ['title' => '图片位置', 'icon' => 'icon-park:graphic-design-two', 'url' => '/banner-addresses'], + ['title' => '图片位置', 'icon' => 'icon-park:graphic-design-two', 'url' => '/banner-places'], ['title' => '图片管理', 'icon' => 'icon-park:picture-album', 'url' => '/banners'], ] ],