goods-brand
parent
a08604bf82
commit
9fcd37b646
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [];
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [];
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'labels' => [
|
||||||
|
'GoodsBrand' => '品牌管理',
|
||||||
|
'goods' => '商品管理',
|
||||||
|
'brand' => '品牌',
|
||||||
|
],
|
||||||
|
'fields' => [
|
||||||
|
'name' => '名称',
|
||||||
|
'image' => '图片',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'labels' => [
|
||||||
|
'GoodsType' => '商品类别',
|
||||||
|
'goods' => '商品管理',
|
||||||
|
'brand' => '类别',
|
||||||
|
],
|
||||||
|
'fields' => [
|
||||||
|
'name' => '名称',
|
||||||
|
'spec' => '规格',
|
||||||
|
'attr' => '属性',
|
||||||
|
'part' => '配件',
|
||||||
|
'values' => '可选值',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!-- $model 当前行数据 -->
|
||||||
|
<!-- $name 字段名称 -->
|
||||||
|
<!-- $value 为当前列的值 -->
|
||||||
|
@if($value)
|
||||||
|
@foreach($value as $item)
|
||||||
|
<div class="mt-1">
|
||||||
|
<span class="label bg-info">{{ $item['name'] }}</span>
|
||||||
|
@if($item['values'])
|
||||||
|
@foreach($item['values'] as $subItem)
|
||||||
|
<span>{{ $subItem }}</span>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
|
@ -5,9 +5,11 @@
|
||||||
@foreach($value as $item)
|
@foreach($value as $item)
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<span class="label bg-info">{{ $item['name'] }}</span>
|
<span class="label bg-info">{{ $item['name'] }}</span>
|
||||||
@foreach($item['values'] as $value)
|
@if($item['values'])
|
||||||
<span>{{ $value['value'] }}({{ $value['price'] }})</span>
|
@foreach($item['values'] as $subItem)
|
||||||
|
<span>{{ $subItem['value'] }}({{ $subItem['price'] }})</span>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ class GoodsServiceProvider extends ServiceProvider
|
||||||
protected $menu = [
|
protected $menu = [
|
||||||
['title' => '商品管理', 'uri' => '', 'icon' => ''],
|
['title' => '商品管理', 'uri' => '', 'icon' => ''],
|
||||||
['title' => '商品分类', 'uri' => 'goods/category', 'icon' => '', 'parent' => '商品管理'],
|
['title' => '商品分类', 'uri' => 'goods/category', 'icon' => '', 'parent' => '商品管理'],
|
||||||
|
['title' => '品牌管理', 'uri' => 'goods/brand', 'icon' => '', 'parent' => '商品管理'],
|
||||||
|
['title' => '商品类别', 'uri' => 'goods/type', 'icon' => '', 'parent' => '商品管理'],
|
||||||
['title' => '商品信息', 'uri' => 'goods', 'icon' => '', 'parent' => '商品管理'],
|
['title' => '商品信息', 'uri' => 'goods', 'icon' => '', 'parent' => '商品管理'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Peidikeji\Goods\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Dcat\Admin\Form;
|
||||||
|
use Dcat\Admin\Grid;
|
||||||
|
use Dcat\Admin\Http\Controllers\AdminController;
|
||||||
|
use Peidikeji\Goods\Models\Goods;
|
||||||
|
use Peidikeji\Goods\Models\GoodsBrand;
|
||||||
|
|
||||||
|
class GoodsBrandController extends AdminController
|
||||||
|
{
|
||||||
|
protected $translation = 'peidikeji.dcat-admin-extension-goods::goods-brand';
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
return Grid::make(new GoodsBrand(), function (Grid $grid) {
|
||||||
|
$grid->disableRowSelector();
|
||||||
|
|
||||||
|
$grid->disableViewButton();
|
||||||
|
|
||||||
|
$grid->column('name');
|
||||||
|
$grid->column('image')->image('', 120);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function form()
|
||||||
|
{
|
||||||
|
return Form::make(new GoodsBrand(), function (Form $form) {
|
||||||
|
$form->text('name');
|
||||||
|
$form->image('image')->autoUpload()->saveFullUrl()->move('goods/brand');
|
||||||
|
|
||||||
|
$form->disableResetButton();
|
||||||
|
$form->disableCreatingCheck();
|
||||||
|
$form->disableViewCheck();
|
||||||
|
$form->disableEditingCheck();
|
||||||
|
|
||||||
|
$form->deleting(function (Form $form) {
|
||||||
|
$data = $form->model()->toArray();
|
||||||
|
foreach($data as $item) {
|
||||||
|
$id = data_get($item, 'id');
|
||||||
|
// 品牌下面包含商品, 阻止删除
|
||||||
|
if (Goods::where('brand_id', $id)->exists()) {
|
||||||
|
return $form->response()->error('请先删除关联的商品');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ class GoodsCategoryController extends AdminController
|
||||||
$form->text('name')->required();
|
$form->text('name')->required();
|
||||||
$form->image('image')
|
$form->image('image')
|
||||||
->uniqueName()
|
->uniqueName()
|
||||||
->move('article-category')
|
->move('goods/category')
|
||||||
->autoUpload();
|
->autoUpload();
|
||||||
$form->number('sort')
|
$form->number('sort')
|
||||||
->min(0)
|
->min(0)
|
||||||
|
|
|
||||||
|
|
@ -93,16 +93,16 @@ class GoodsController extends AdminController
|
||||||
$form->image('cover_image')
|
$form->image('cover_image')
|
||||||
->autoUpload()
|
->autoUpload()
|
||||||
->saveFullUrl()
|
->saveFullUrl()
|
||||||
->move('goods')
|
->move('goods/goods')
|
||||||
->required();
|
->required();
|
||||||
$form->multipleImage('images')
|
$form->multipleImage('images')
|
||||||
->autoUpload()
|
->autoUpload()
|
||||||
->saveFullUrl()
|
->saveFullUrl()
|
||||||
->move('goods');
|
->move('goods/goods');
|
||||||
$form->multipleImage('content')
|
$form->multipleImage('content')
|
||||||
->autoUpload()
|
->autoUpload()
|
||||||
->saveFullUrl()
|
->saveFullUrl()
|
||||||
->move('goods');
|
->move('goods/goods');
|
||||||
|
|
||||||
$form->number('price')->min(0)->attribute('step', 0.01);
|
$form->number('price')->min(0)->attribute('step', 0.01);
|
||||||
$form->switch('on_sale');
|
$form->switch('on_sale');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Peidikeji\Goods\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Dcat\Admin\Form;
|
||||||
|
use Dcat\Admin\Form\NestedForm;
|
||||||
|
use Dcat\Admin\Grid;
|
||||||
|
use Dcat\Admin\Http\Controllers\AdminController;
|
||||||
|
use Peidikeji\Goods\Models\Goods;
|
||||||
|
use Peidikeji\Goods\Models\GoodsType;
|
||||||
|
|
||||||
|
class GoodsTypeController extends AdminController
|
||||||
|
{
|
||||||
|
protected $translation = 'peidikeji.dcat-admin-extension-goods::goods-type';
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
return Grid::make(new GoodsType(), function (Grid $grid) {
|
||||||
|
$grid->disableRowSelector();
|
||||||
|
$grid->disableViewButton();
|
||||||
|
|
||||||
|
$grid->column('name');
|
||||||
|
$grid->column('attr')->view('peidikeji.dcat-admin-extension-goods::grid.part');
|
||||||
|
$grid->column('spec')->view('peidikeji.dcat-admin-extension-goods::grid.part');
|
||||||
|
$grid->column('part')->view('peidikeji.dcat-admin-extension-goods::grid.part');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function form()
|
||||||
|
{
|
||||||
|
return Form::make(new GoodsType(), function (Form $form) {
|
||||||
|
$form->text('name');
|
||||||
|
|
||||||
|
$form->array('attr', function (NestedForm $table) {
|
||||||
|
$table->text('name')->required();
|
||||||
|
$table->list('values');
|
||||||
|
});
|
||||||
|
$form->array('spec', function (NestedForm $table) {
|
||||||
|
$table->text('name')->required();
|
||||||
|
$table->list('values');
|
||||||
|
});
|
||||||
|
$form->array('part', function (NestedForm $table) {
|
||||||
|
$table->text('name')->required();
|
||||||
|
$table->list('values');
|
||||||
|
});
|
||||||
|
|
||||||
|
$form->disableResetButton();
|
||||||
|
$form->disableCreatingCheck();
|
||||||
|
$form->disableViewCheck();
|
||||||
|
$form->disableEditingCheck();
|
||||||
|
|
||||||
|
$form->deleting(function (Form $form) {
|
||||||
|
$data = $form->model()->toArray();
|
||||||
|
foreach($data as $item) {
|
||||||
|
$id = data_get($item, 'id');
|
||||||
|
// 下面包含商品, 阻止删除
|
||||||
|
if (Goods::where('type_id', $id)->exists()) {
|
||||||
|
return $form->response()->error('请先删除关联的商品');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,5 +5,7 @@ namespace Peidikeji\Goods\Http\Controllers\Admin;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::resource('goods/category', GoodsCategoryController::class);
|
Route::resource('goods/category', GoodsCategoryController::class);
|
||||||
|
Route::resource('goods/brand', GoodsBrandController::class);
|
||||||
|
Route::resource('goods/type', GoodsTypeController::class);
|
||||||
|
|
||||||
Route::resource('goods', GoodsController::class);
|
Route::resource('goods', GoodsController::class);
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,9 @@ class GoodsBrand extends Model
|
||||||
protected $fillable = ['name', 'image'];
|
protected $fillable = ['name', 'image'];
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function goods()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Goods::class, 'brand_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ class CreateGoodsTable extends Migration
|
||||||
$table->unsignedInteger('stock')->default(0)->comment('库存');
|
$table->unsignedInteger('stock')->default(0)->comment('库存');
|
||||||
$table->unsignedInteger('sold_count')->default(0)->comment('销量');
|
$table->unsignedInteger('sold_count')->default(0)->comment('销量');
|
||||||
$table->decimal('price', 12, 2)->comment('售价');
|
$table->decimal('price', 12, 2)->comment('售价');
|
||||||
$table->json('attr')->nullable()->comment('属性');
|
$table->json('attr')->nullable()->comment('属性[{name, value}]');
|
||||||
$table->json('spec')->nullable()->comment('规格');
|
$table->json('spec')->nullable()->comment('规格[{name, values: [{value, price}]}]');
|
||||||
$table->json('part')->nullable()->comment('配件');
|
$table->json('part')->nullable()->comment('配件[{name, values: [{value, price}]}]');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ class CreateGoodsTable extends Migration
|
||||||
$table->string('name')->comment('名称');
|
$table->string('name')->comment('名称');
|
||||||
$table->decimal('price', 12, 2)->comment('价格');
|
$table->decimal('price', 12, 2)->comment('价格');
|
||||||
$table->unsignedInteger('stock')->comment('库存');
|
$table->unsignedInteger('stock')->comment('库存');
|
||||||
$table->json('spec')->nullable()->comment('规格');
|
$table->json('spec')->nullable()->comment('规格[{name, value, price}]');
|
||||||
|
|
||||||
$table->foreign('goods_id')->references('id')->on('goods');
|
$table->foreign('goods_id')->references('id')->on('goods');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue