123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace App\Community\Controllers;
- use App\Models\Order;
- use App\Models\Vaccine;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Show;
- class VaccineController extends AdminController
- {
- /**
- * Title for current resource.
- *
- * @var string
- */
- protected $title = '用户管理';
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new Vaccine());
- $grid->disableCreateButton(false);
- $grid->column('id', __('ID'));
- $grid->column('name', __('疫苗名称'));
- $grid->column('type', __('类别'))->editable('select',[1=>'一类',2=>'二类']);
- $grid->column('stock', __('剩余库存'))->editable();
- $grid->column('used_num', __('已使用量'))->display(function (){
- Order::where(['product_type'=>4,'organization_id'=>$org_id])->wherehas('orderVaccine',function ($query){
- });
- });
- $grid->column('today_num', __('今日预约'));
- $grid->column('price', __('价格'))->editable();
- $grid->column('remark', __('备注'))->editable('textarea');
- $grid->column('supplier', __('厂家'));
- // $grid->column('created_at', __('Created at'));
- // $grid->column('updated_at', __('Updated at'));
- $grid->filter(function ($fliter){
- $fliter->equal('type','类别')->select([1=>'一类',2=>'二类']);
- // $fliter->equal('type','类别')->select([1=>'一类',2=>'二类']);
- });
- $grid->actions(function ($actions) {
- // append一个操作
- $actions->append('<a href=""><i class="fa fa-header">跳转</i></a>');
- // prepend一个操作
- $actions->prepend('<a href="http://www.baidu.com" target="_blank"><i class="fa fa-cab"></i></a>');
- });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(Vaccine::findOrFail($id));
- $show->field('id', __('Id'));
- $show->field('type', __('Type'));
- $show->field('price', __('Price'));
- $show->field('name', __('Name'));
- $show->field('remark', __('Remark'));
- $show->field('supplier', __('Supplier'));
- $show->field('created_at', __('Created at'));
- $show->field('updated_at', __('Updated at'));
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new Vaccine());
- $form->select('type', __('类型'))->options([1=>'一类',2=>'二类']);
- $form->text('name', __('疫苗名称'));
- $form->text('supplier', __('厂家'));
- $form->number('price', __('价格'));
- $form->textarea('remark', __('备注'));
- return $form;
- }
- }
|