6
0
Fork 0

添加商品购买须知模板

release
vine_liutk 2021-11-30 11:13:15 +08:00
parent 13725c3fc0
commit dae030c2fc
11 changed files with 175 additions and 0 deletions

View File

@ -0,0 +1,85 @@
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\ProductBuynote;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;
class ProductBuynoteController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new ProductBuynote(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('name');
// $grid->column('content');
$grid->column('created_at')->sortable();
//排序
$grid->model()->orderBy('created_at', 'desc');
/** 操作 **/
//新增
if (Admin::user()->can('dcat.admin.product_buynotes.create')) {
$grid->disableCreateButton(false);
// $grid->enableDialogCreate();
}
//删除以及自定义操作
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->disableEdit(Admin::user()->cannot('dcat.admin.product_buynotes.edit'));
$actions->disableDelete(Admin::user()->cannot('dcat.admin.product_buynotes.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 ProductBuynote(), function (Show $show) {
$show->field('id');
$show->field('name');
$show->field('content');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new ProductBuynote(), function (Form $form) {
$form->display('id');
$form->text('name')->required();
$form->editor('content');
$form->display('created_at');
$form->display('updated_at');
});
}
}

View File

@ -3,6 +3,7 @@
namespace App\Admin\Controllers;
use App\Admin\Repositories\ProductSpu;
use App\Models\ProductBuynote;
use App\Models\ProductFeature;
use App\Models\ProductGroup;
use Carbon\Carbon;
@ -121,6 +122,7 @@ class ProductSpuController extends AdminController
return array_column($v, 'id');
});
$form->editor('description');
$form->select('buynot_id')->options(ProductBuynote::all()->pluck('name', 'id'));
$form->number('weight');
$form->currency('sell_price')->symbol('¥')->default(0);

View File

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

View File

@ -43,6 +43,10 @@ Route::group([
'index', 'create', 'store', 'edit', 'update', 'destroy',
])->names('product_features');
$router->resource('product-buynotes', 'ProductBuynoteController')->only([
'index', 'create', 'store', 'edit', 'update', 'destroy',
])->names('product_buynotes');
$router->resource('product-spus', 'ProductSpuController')->names('product_spus');

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 ProductBuynote extends Model
{
use HasFactory;
use HasDateTimeFormatter;
}

View File

@ -31,6 +31,7 @@ class CreateProductSpusTable extends Migration
$table->integer('stock')->unsigned()->default(0)->comment('库存');
$table->integer('sales')->unsigned()->default(0)->comment('销量');
$table->timestamp('release_at')->nullable()->comment('上架时间');
$table->unsignedBigInteger('buynote_id')->nullable()->comment('购买须知模板ID');
$table->timestamps();
$table->index('category_id');

View File

@ -33,6 +33,8 @@ class CreateProductSkusTable extends Migration
$table->integer('stock')->unsigned()->default(0)->comment('库存');
$table->integer('sales')->unsigned()->default(0)->comment('销量');
$table->timestamp('release_at')->nullable()->comment('上架时间');
$table->tinyInteger('verify_state')->unsigned()->default(0)->comment('审核状态:0正常1处理中2处理失败');
$table->unsignedBigInteger('buynote_id')->nullable()->comment('购买须知模板ID');
$table->timestamps();
$table->index('spu_id');

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProductBuynotesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product_buynotes', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('模板名称');
$table->text('content')->nullable()->comment('模板内容');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('product_buynotes');
}
}

View File

@ -79,6 +79,7 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection stock
* @property Grid\Column|Collection sales
* @property Grid\Column|Collection release_at
* @property Grid\Column|Collection feature_id
* @property Grid\Column|Collection product_spu_id
* @property Grid\Column|Collection items
* @property Grid\Column|Collection is_sell
@ -167,6 +168,7 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection stock(string $label = null)
* @method Grid\Column|Collection sales(string $label = null)
* @method Grid\Column|Collection release_at(string $label = null)
* @method Grid\Column|Collection feature_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)
@ -260,6 +262,7 @@ namespace Dcat\Admin {
* @property Show\Field|Collection stock
* @property Show\Field|Collection sales
* @property Show\Field|Collection release_at
* @property Show\Field|Collection feature_id
* @property Show\Field|Collection product_spu_id
* @property Show\Field|Collection items
* @property Show\Field|Collection is_sell
@ -348,6 +351,7 @@ namespace Dcat\Admin {
* @method Show\Field|Collection stock(string $label = null)
* @method Show\Field|Collection sales(string $label = null)
* @method Show\Field|Collection release_at(string $label = null)
* @method Show\Field|Collection feature_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)

View File

@ -0,0 +1,14 @@
<?php
return [
'labels' => [
'ProductBuynote' => '商品购买须知',
'product-buynotes' => '商品购买须知',
],
'fields' => [
'name' => '模板名称',
'content' => '模板内容',
],
'options' => [
],
];

View File

@ -15,6 +15,7 @@ return [
'images' => '商品图片',
'features' => '商品特点',
'description' => '商品详情',
'buynot_id'=>'购买须知模板',
'sell_price' => '销售价格',
'market_price' => '市场价格',
'cost_price' => '成本价格',