Update
parent
7946dbb8c8
commit
cec1fad4bc
|
|
@ -72,13 +72,14 @@ class OfflineOrderController extends AdminController
|
|||
});
|
||||
$grid->column('items')->display(function ($items) {
|
||||
return $items->map(function ($item) {
|
||||
$color = $item->productCategory?->color ?? '#586cb1';
|
||||
$category = $item->productCategory?->name;
|
||||
|
||||
if ($discount = $item->getDiscount()) {
|
||||
$category .= " {$discount}折";
|
||||
}
|
||||
|
||||
return '<span class="label bg-primary d-inline-block mb-25 mr-25">'.$category.'</span>';
|
||||
return "<span class=\"label text-md d-inline-block text- mb-25 mr-25 p-50\" style=\"background-color:{$color}\">{$category}</span>";
|
||||
})->join('');
|
||||
});
|
||||
$grid->column('products_total_amount')->display(fn($v) => bcdiv($v, 100, 2))->prepend('¥');
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class OfflineProductCategoryController extends AdminController
|
|||
->else(function (Column $column) {
|
||||
$column->bool();
|
||||
});
|
||||
$grid->column('color')->display(fn ($v) => $v ? "<span class=\"label\" style=\"background-color:{$v}\">{$v}</span>" : '');
|
||||
$grid->column('sort')->sortable();
|
||||
$grid->column('created_at');
|
||||
|
||||
|
|
@ -72,6 +73,8 @@ class OfflineProductCategoryController extends AdminController
|
|||
->setLabelClass(['asterisk'])
|
||||
->attribute('required', true);
|
||||
|
||||
$form->color('color');
|
||||
|
||||
$form->switch('enabled')
|
||||
->default(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class OfflineProductCategory extends Model
|
|||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'enabled', 'sort',
|
||||
'name', 'enabled', 'color', 'sort',
|
||||
];
|
||||
|
||||
public function scopeEnabled(Builder $builder)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddColorToOfflineProductCategoriesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('offline_product_categories', function (Blueprint $table) {
|
||||
$table->string('color')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('offline_product_categories', function (Blueprint $table) {
|
||||
$table->dropColumn(['color']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ return [
|
|||
'fields' => [
|
||||
'name' => '名称',
|
||||
'enabled' => '启用',
|
||||
'color' => '颜色',
|
||||
'sort' => '排序',
|
||||
],
|
||||
'options' => [
|
||||
|
|
|
|||
Loading…
Reference in New Issue