1
0
Fork 0

添加图片管理样式

develop
vine_liutk 2023-03-20 15:59:08 +08:00
parent 7adb8316e1
commit c7c3c9cd39
11 changed files with 248 additions and 2 deletions

View File

@ -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(),

View File

@ -0,0 +1,59 @@
<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\TableColumn;
use Slowlyo\OwlAdmin\Renderers\TextControl;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Services\Admin\BannerService;
use App\Admin\Components;
class BannerController extends AdminController
{
protected string $serviceName = BannerService::class;
protected string $pageTitle = '图片管理';//待完善-todo
public function list(): Page
{
$crud = $this->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('更新时间')
]);
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\TableColumn;
use Slowlyo\OwlAdmin\Renderers\TextControl;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Services\Admin\BannerPlaceService;
class BannerPlaceController extends AdminController
{
protected string $serviceName = BannerPlaceService::class;
protected string $pageTitle = '图片位置';//待完善-todo
public function list(): Page
{
$crud = $this->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('更新时间')
]);
}
}

View File

@ -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);

View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Banner extends Model
{
use HasFactory;
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class BannerPlace extends Model
{
use HasFactory;
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Services\Admin;
use App\Models\BannerPlace;
use Slowlyo\OwlAdmin\Services\AdminService;
/**
* @method BannerPlace getModel()
* @method BannerPlace|\Illuminate\Database\Query\Builder query()
*/
class BannerPlaceService extends AdminService
{
protected string $modelName = BannerPlace::class;
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Services\Admin;
use App\Models\Banner;
use Slowlyo\OwlAdmin\Services\AdminService;
/**
* @method Banner getModel()
* @method Banner|\Illuminate\Database\Query\Builder query()
*/
class BannerService extends AdminService
{
protected string $modelName = Banner::class;
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('banner_places', function (Blueprint $table) {
$table->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');
}
};

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('banners', function (Blueprint $table) {
$table->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');
}
};

View File

@ -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'],
]
],