You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.8 KiB
105 lines
2.8 KiB
<?php
|
|
|
|
namespace App\AdminGuide\Controllers;
|
|
|
|
use App\AdminAgent\Repositories\DemandBidding;
|
|
use App\Traits\DemandTraits;
|
|
use Dcat\Admin\Admin;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use http\Env\Request;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class DemandBiddingController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new DemandBidding(['demand']), function (Grid $grid) {
|
|
$grid->model()->where(['bidding_user_id' => Admin::user()->id,'bidding_user_type' => DemandTraits::$col[2]]);
|
|
$grid->column('id')->sortable();
|
|
$grid->column('price');
|
|
$grid->column('comment');
|
|
$grid->column('demand.title','竞拍标题');
|
|
$grid->column('demand.comment','竞拍内容')
|
|
->display('查看')
|
|
->modal('详情',function ($modal) {
|
|
$modal->xl();
|
|
return $this->demand->comment;
|
|
});
|
|
|
|
$grid->column('state','状态')->using(DemandTraits::$biddingState)->dot(
|
|
[
|
|
'yellow',
|
|
'success',
|
|
'danger',
|
|
]
|
|
);
|
|
$grid->column('created_at');
|
|
$grid->column('updated_at')->sortable();
|
|
$grid->disableDeleteButton();
|
|
$grid->disableEditButton();
|
|
$grid->disableQuickEditButton();
|
|
$grid->disableViewButton();
|
|
$grid->disableCreateButton();
|
|
$grid->disableActions();
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->equal('id');
|
|
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new DemandBidding(), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('price');
|
|
$show->field('comment');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new DemandBidding(), function (Form $form) {
|
|
$form->disableEditingCheck();
|
|
$form->disableCreatingCheck();
|
|
$form->disableViewCheck();
|
|
$form->display('id');
|
|
$form->text('price');
|
|
$form->textarea('comment');
|
|
$form->hidden('demand_id')->value(request('demand_id',0));
|
|
$form->hidden('bidding_user_type');
|
|
$form->hidden('bidding_user_id');
|
|
$form->saving(function (Form $form) {
|
|
// 判断是否是新增操作
|
|
if ($form->isCreating()) {
|
|
//发布人身份
|
|
$form->bidding_user_type = DemandTraits::$col[2];
|
|
$form->bidding_user_id = Admin::user()->id;
|
|
}
|
|
$form->response()->success('操作成功')->redirect('demand_bidding');
|
|
});
|
|
});
|
|
}
|
|
}
|