33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Renderable;
|
|
|
|
use App\Models\DealerUserProductLog;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Grid\LazyRenderable;
|
|
|
|
class DealerUserProductLogSimpleTable extends LazyRenderable
|
|
{
|
|
public function grid(): Grid
|
|
{
|
|
$userId = $this->payload['id'] ?? 0;
|
|
$productId = $this->payload['product_id'] ?? 0;
|
|
|
|
$builder = DealerUserProductLog::query();
|
|
$builder->with(['product'])->where(['user_id'=>$userId, 'product_id'=>$productId]);
|
|
return Grid::make($builder, function (Grid $grid) {
|
|
$grid->column('product.name', '商品名称');
|
|
$grid->column('remark', '备注');
|
|
$grid->column('qty', '变动数量')->display(function () {
|
|
return ($this->type == DealerUserProductLog::TYPE_ORDER_IN ? '+' : '-').$this->qty.$this->product?->unit;
|
|
});
|
|
$grid->column('created_at', '创建时间');
|
|
|
|
// $grid->withBorder();
|
|
$grid->model()->orderBy('created_at', 'desc');
|
|
$grid->disableRefreshButton();
|
|
$grid->disableActions();
|
|
});
|
|
}
|
|
}
|