6
0
Fork 0

添加商品特点管理

release
vine_liutk 2021-11-30 10:03:07 +08:00
parent a795b3ec73
commit 8a7861d097
7 changed files with 216 additions and 25 deletions

View File

@ -0,0 +1,94 @@
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\ProductFeature;
use Carbon\Carbon;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;
class ProductFeatureController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new ProductFeature(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('name');
$grid->column('icon')->image(50, 50);
$grid->column('remarks');
$grid->column('created_at')->sortable();
//排序
$grid->model()->orderBy('created_at', 'desc');
/** 操作 **/
//新增
if (Admin::user()->can('dcat.admin.product_features.create')) {
$grid->disableCreateButton(false);
$grid->enableDialogCreate();
}
//修改
$grid->showQuickEditButton(Admin::user()->can('dcat.admin.product_features.edit'));
//删除以及自定义操作
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->disableDelete(Admin::user()->cannot('dcat.admin.product_features.destroy'));
});
/** 查询 **/
$grid->filter(function (Grid\Filter $filter) {
$filter->panel();
$filter->like('name')->width(3);
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new ProductFeature(), function (Show $show) {
$show->field('id');
$show->field('name');
$show->field('icon');
$show->field('remarks');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new ProductFeature(), function (Form $form) {
$form->display('id');
$form->text('name')->required();
$form->image('icon')
->move('product-features/'.Carbon::now()->toDateString())
->saveFullUrl()
->removable(false)
->autoUpload();
$form->text('remarks');
$form->display('created_at');
$form->display('updated_at');
});
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Admin\Repositories;
use App\Models\ProductFeature as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class ProductFeature extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}

View File

@ -39,9 +39,15 @@ Route::group([
'index', 'create', 'store', 'edit', 'update', 'destroy', 'index', 'create', 'store', 'edit', 'update', 'destroy',
])->names('product_groups'); ])->names('product_groups');
$router->resource('product-features', 'ProductFeatureController')->only([
'index', 'create', 'store', 'edit', 'update', 'destroy',
])->names('product_features');
$router->resource('product-spus', 'ProductSpuController')->names('product_spus'); $router->resource('product-spus', 'ProductSpuController')->names('product_spus');
/** api接口 **/ /** api接口 **/
$router->get('api/product-categories', 'ProductCategoryController@list')->name('api.product_categories'); $router->get('api/product-categories', 'ProductCategoryController@list')->name('api.product_categories');
$router->get('api/product-group-details', 'ProductGroupController@details')->name('api.product_group_details'); $router->get('api/product-group-details', 'ProductGroupController@details')->name('api.product_group_details');

View File

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ProductFeature extends Model
{
use HasFactory;
use HasDateTimeFormatter;
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProductFeaturesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product_features', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('名称');
$table->string('icon')->nullable()->comment('图标');
$table->string('remarks')->nullable()->comment('备注');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('product_features');
}
}

View File

@ -63,22 +63,25 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection token * @property Grid\Column|Collection token
* @property Grid\Column|Collection abilities * @property Grid\Column|Collection abilities
* @property Grid\Column|Collection last_used_at * @property Grid\Column|Collection last_used_at
* @property Grid\Column|Collection group_id * @property Grid\Column|Collection remarks
* @property Grid\Column|Collection attrs * @property Grid\Column|Collection attrs
* @property Grid\Column|Collection specs
* @property Grid\Column|Collection part_id
* @property Grid\Column|Collection sku_id
* @property Grid\Column|Collection spu_id * @property Grid\Column|Collection spu_id
* @property Grid\Column|Collection images * @property Grid\Column|Collection images
* @property Grid\Column|Collection sell_price * @property Grid\Column|Collection sell_price
* @property Grid\Column|Collection market_price * @property Grid\Column|Collection market_price
* @property Grid\Column|Collection cost_price * @property Grid\Column|Collection cost_price
* @property Grid\Column|Collection user_price * @property Grid\Column|Collection vip_price
* @property Grid\Column|Collection media * @property Grid\Column|Collection media
* @property Grid\Column|Collection weight * @property Grid\Column|Collection weight
* @property Grid\Column|Collection is_sell
* @property Grid\Column|Collection spec_items
* @property Grid\Column|Collection stock * @property Grid\Column|Collection stock
* @property Grid\Column|Collection sells * @property Grid\Column|Collection sales
* @property Grid\Column|Collection items * @property Grid\Column|Collection release_at
* @property Grid\Column|Collection product_spu_id * @property Grid\Column|Collection product_spu_id
* @property Grid\Column|Collection items
* @property Grid\Column|Collection is_sell
* @property Grid\Column|Collection phone * @property Grid\Column|Collection phone
* @property Grid\Column|Collection code * @property Grid\Column|Collection code
* @property Grid\Column|Collection is_use * @property Grid\Column|Collection is_use
@ -148,22 +151,25 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection token(string $label = null) * @method Grid\Column|Collection token(string $label = null)
* @method Grid\Column|Collection abilities(string $label = null) * @method Grid\Column|Collection abilities(string $label = null)
* @method Grid\Column|Collection last_used_at(string $label = null) * @method Grid\Column|Collection last_used_at(string $label = null)
* @method Grid\Column|Collection group_id(string $label = null) * @method Grid\Column|Collection remarks(string $label = null)
* @method Grid\Column|Collection attrs(string $label = null) * @method Grid\Column|Collection attrs(string $label = null)
* @method Grid\Column|Collection specs(string $label = null)
* @method Grid\Column|Collection part_id(string $label = null)
* @method Grid\Column|Collection sku_id(string $label = null)
* @method Grid\Column|Collection spu_id(string $label = null) * @method Grid\Column|Collection spu_id(string $label = null)
* @method Grid\Column|Collection images(string $label = null) * @method Grid\Column|Collection images(string $label = null)
* @method Grid\Column|Collection sell_price(string $label = null) * @method Grid\Column|Collection sell_price(string $label = null)
* @method Grid\Column|Collection market_price(string $label = null) * @method Grid\Column|Collection market_price(string $label = null)
* @method Grid\Column|Collection cost_price(string $label = null) * @method Grid\Column|Collection cost_price(string $label = null)
* @method Grid\Column|Collection user_price(string $label = null) * @method Grid\Column|Collection vip_price(string $label = null)
* @method Grid\Column|Collection media(string $label = null) * @method Grid\Column|Collection media(string $label = null)
* @method Grid\Column|Collection weight(string $label = null) * @method Grid\Column|Collection weight(string $label = null)
* @method Grid\Column|Collection is_sell(string $label = null)
* @method Grid\Column|Collection spec_items(string $label = null)
* @method Grid\Column|Collection stock(string $label = null) * @method Grid\Column|Collection stock(string $label = null)
* @method Grid\Column|Collection sells(string $label = null) * @method Grid\Column|Collection sales(string $label = null)
* @method Grid\Column|Collection items(string $label = null) * @method Grid\Column|Collection release_at(string $label = null)
* @method Grid\Column|Collection product_spu_id(string $label = null) * @method Grid\Column|Collection product_spu_id(string $label = null)
* @method Grid\Column|Collection items(string $label = null)
* @method Grid\Column|Collection is_sell(string $label = null)
* @method Grid\Column|Collection phone(string $label = null) * @method Grid\Column|Collection phone(string $label = null)
* @method Grid\Column|Collection code(string $label = null) * @method Grid\Column|Collection code(string $label = null)
* @method Grid\Column|Collection is_use(string $label = null) * @method Grid\Column|Collection is_use(string $label = null)
@ -238,22 +244,25 @@ namespace Dcat\Admin {
* @property Show\Field|Collection token * @property Show\Field|Collection token
* @property Show\Field|Collection abilities * @property Show\Field|Collection abilities
* @property Show\Field|Collection last_used_at * @property Show\Field|Collection last_used_at
* @property Show\Field|Collection group_id * @property Show\Field|Collection remarks
* @property Show\Field|Collection attrs * @property Show\Field|Collection attrs
* @property Show\Field|Collection specs
* @property Show\Field|Collection part_id
* @property Show\Field|Collection sku_id
* @property Show\Field|Collection spu_id * @property Show\Field|Collection spu_id
* @property Show\Field|Collection images * @property Show\Field|Collection images
* @property Show\Field|Collection sell_price * @property Show\Field|Collection sell_price
* @property Show\Field|Collection market_price * @property Show\Field|Collection market_price
* @property Show\Field|Collection cost_price * @property Show\Field|Collection cost_price
* @property Show\Field|Collection user_price * @property Show\Field|Collection vip_price
* @property Show\Field|Collection media * @property Show\Field|Collection media
* @property Show\Field|Collection weight * @property Show\Field|Collection weight
* @property Show\Field|Collection is_sell
* @property Show\Field|Collection spec_items
* @property Show\Field|Collection stock * @property Show\Field|Collection stock
* @property Show\Field|Collection sells * @property Show\Field|Collection sales
* @property Show\Field|Collection items * @property Show\Field|Collection release_at
* @property Show\Field|Collection product_spu_id * @property Show\Field|Collection product_spu_id
* @property Show\Field|Collection items
* @property Show\Field|Collection is_sell
* @property Show\Field|Collection phone * @property Show\Field|Collection phone
* @property Show\Field|Collection code * @property Show\Field|Collection code
* @property Show\Field|Collection is_use * @property Show\Field|Collection is_use
@ -323,22 +332,25 @@ namespace Dcat\Admin {
* @method Show\Field|Collection token(string $label = null) * @method Show\Field|Collection token(string $label = null)
* @method Show\Field|Collection abilities(string $label = null) * @method Show\Field|Collection abilities(string $label = null)
* @method Show\Field|Collection last_used_at(string $label = null) * @method Show\Field|Collection last_used_at(string $label = null)
* @method Show\Field|Collection group_id(string $label = null) * @method Show\Field|Collection remarks(string $label = null)
* @method Show\Field|Collection attrs(string $label = null) * @method Show\Field|Collection attrs(string $label = null)
* @method Show\Field|Collection specs(string $label = null)
* @method Show\Field|Collection part_id(string $label = null)
* @method Show\Field|Collection sku_id(string $label = null)
* @method Show\Field|Collection spu_id(string $label = null) * @method Show\Field|Collection spu_id(string $label = null)
* @method Show\Field|Collection images(string $label = null) * @method Show\Field|Collection images(string $label = null)
* @method Show\Field|Collection sell_price(string $label = null) * @method Show\Field|Collection sell_price(string $label = null)
* @method Show\Field|Collection market_price(string $label = null) * @method Show\Field|Collection market_price(string $label = null)
* @method Show\Field|Collection cost_price(string $label = null) * @method Show\Field|Collection cost_price(string $label = null)
* @method Show\Field|Collection user_price(string $label = null) * @method Show\Field|Collection vip_price(string $label = null)
* @method Show\Field|Collection media(string $label = null) * @method Show\Field|Collection media(string $label = null)
* @method Show\Field|Collection weight(string $label = null) * @method Show\Field|Collection weight(string $label = null)
* @method Show\Field|Collection is_sell(string $label = null)
* @method Show\Field|Collection spec_items(string $label = null)
* @method Show\Field|Collection stock(string $label = null) * @method Show\Field|Collection stock(string $label = null)
* @method Show\Field|Collection sells(string $label = null) * @method Show\Field|Collection sales(string $label = null)
* @method Show\Field|Collection items(string $label = null) * @method Show\Field|Collection release_at(string $label = null)
* @method Show\Field|Collection product_spu_id(string $label = null) * @method Show\Field|Collection product_spu_id(string $label = null)
* @method Show\Field|Collection items(string $label = null)
* @method Show\Field|Collection is_sell(string $label = null)
* @method Show\Field|Collection phone(string $label = null) * @method Show\Field|Collection phone(string $label = null)
* @method Show\Field|Collection code(string $label = null) * @method Show\Field|Collection code(string $label = null)
* @method Show\Field|Collection is_use(string $label = null) * @method Show\Field|Collection is_use(string $label = null)
@ -359,7 +371,8 @@ namespace Dcat\Admin {
class Show {} class Show {}
/** /**
* @method \App\Admin\Extensions\Form\Product\SelectAttr selectAttr(...$params)
* @method \App\Admin\Extensions\Form\Product\SelectSpec selectSpec(...$params)
*/ */
class Form {} class Form {}

View File

@ -0,0 +1,15 @@
<?php
return [
'labels' => [
'ProductFeature' => '商品特点',
'product-features' => '商品特点',
],
'fields' => [
'name' => '名称',
'icon' => '图标',
'remarks' => '备注',
],
'options' => [
],
];