2 changed files with 135 additions and 0 deletions
@ -0,0 +1,119 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\AdminGuide\Controllers; |
||||
|
|
||||
|
use App\AdminGuide\Repositories\Order; |
||||
|
use App\Common\OrderStatus; |
||||
|
use App\Common\PayType; |
||||
|
use App\Models\Agent; |
||||
|
use App\Models\Supplier; |
||||
|
use Dcat\Admin\Form; |
||||
|
use Dcat\Admin\Grid; |
||||
|
use Dcat\Admin\Show; |
||||
|
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
|
||||
|
class OrderController extends AdminController |
||||
|
{ |
||||
|
/** |
||||
|
* Make a grid builder. |
||||
|
* |
||||
|
* @return Grid |
||||
|
*/ |
||||
|
protected function grid() |
||||
|
{ |
||||
|
return Grid::make(new Order(['agent:id,name', 'user:id,nickname']), function (Grid $grid) { |
||||
|
$grid->disableBatchActions(); |
||||
|
$grid->disableCreateButton(); |
||||
|
$grid->disableActions(); |
||||
|
|
||||
|
//TODO 此处需要再加筛选条件
|
||||
|
|
||||
|
$grid->column('id')->sortable(); |
||||
|
$grid->column('agent.name'); |
||||
|
$grid->column('order_no')->limit(10); |
||||
|
$grid->column('num'); |
||||
|
$grid->column('price'); |
||||
|
$grid->column('name'); |
||||
|
$grid->column('mobile'); |
||||
|
$grid->column('title')->limit(15); |
||||
|
$grid->column('picture')->image('', 60, 60); |
||||
|
$grid->column('status')->using(OrderStatus::array()); |
||||
|
$grid->column('pay_type')->using(PayType::array()); |
||||
|
$grid->column('paid_money'); |
||||
|
$grid->column('paid_at'); |
||||
|
$grid->column('created_at'); |
||||
|
|
||||
|
$grid->filter(function (Grid\Filter $filter) { |
||||
|
$filter->panel(); |
||||
|
|
||||
|
$filter->equal('id')->width(2); |
||||
|
$filter->equal('mobile')->width(2); |
||||
|
$filter->equal('order_no')->width(3); |
||||
|
$filter->equal('status')->select(OrderStatus::array())->width(2); |
||||
|
|
||||
|
$option = Agent::query()->pluck('name', 'id'); |
||||
|
$filter->equal('agent_id', '代理商')->select($option)->width(3); |
||||
|
|
||||
|
$option = Supplier::query()->pluck('name', 'id'); |
||||
|
$filter->equal('product.supplier_id', '供应商')->select($option)->width(3); |
||||
|
|
||||
|
$filter->between('created_at')->datetime()->width(4); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Make a show builder. |
||||
|
* |
||||
|
* @param mixed $id |
||||
|
* |
||||
|
* @return Show |
||||
|
*/ |
||||
|
protected function detail($id) |
||||
|
{ |
||||
|
return Show::make($id, new Order(), function (Show $show) { |
||||
|
$show->disableDeleteButton(); |
||||
|
$show->disableEditButton(); |
||||
|
|
||||
|
$show->field('id'); |
||||
|
/*$show->field('user_id'); |
||||
|
$show->field('agent_id'); |
||||
|
$show->field('order_no'); |
||||
|
$show->field('agent_product_id'); |
||||
|
$show->field('product_id'); |
||||
|
$show->field('product_ids'); |
||||
|
$show->field('num'); |
||||
|
$show->field('price'); |
||||
|
$show->field('name'); |
||||
|
$show->field('mobile'); |
||||
|
$show->field('title'); |
||||
|
$show->field('picture'); |
||||
|
$show->field('status'); |
||||
|
$show->field('pay_type'); |
||||
|
$show->field('paid_money'); |
||||
|
$show->field('paid_at'); |
||||
|
$show->field('created_at'); |
||||
|
$show->field('updated_at');*/ |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Make a form builder. |
||||
|
* |
||||
|
* @return Form |
||||
|
*/ |
||||
|
protected function form() |
||||
|
{ |
||||
|
return Form::make(new Order(), function (Form $form) { |
||||
|
$form->disableDeleteButton(); |
||||
|
$form->disableFooter(); |
||||
|
$form->disableViewButton(); |
||||
|
|
||||
|
$form->display('id'); |
||||
|
})->saving(function (Form $form) { |
||||
|
return $form->response()->error('操作禁止'); |
||||
|
})->deleting(function (Form $form) { |
||||
|
return $form->response()->error('操作禁止'); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\AdminGuide\Repositories; |
||||
|
|
||||
|
use App\Models\Order as Model; |
||||
|
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
|
||||
|
class Order extends EloquentRepository |
||||
|
{ |
||||
|
/** |
||||
|
* Model. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $eloquentClass = Model::class; |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue