old-hotel-charge/app/Admin/Controllers/OldmanController.php

134 lines
4.4 KiB
PHP

<?php
namespace App\Admin\Controllers;
use App\Models\Oldman;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class OldmanController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Oldman(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('floor_name');
$grid->column('agreement_no');
$grid->column('name');
$grid->column('card_no');
$grid->column('sex');
$grid->column('age');
$grid->column('client_name');
$grid->column('client_phone');
$grid->column('nurse_lv');
$grid->column('created_at')->sortable();
// $grid->column('updated_at')
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('name')->width(3);
$filter->equal('card_no')->width(3);
$filter->equal('nurse_lv')->select()->width(3);
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Oldman(), function (Show $show) {
$show->field('id');
$show->field('floor_name');
$show->field('agreement_no');
$show->field('name');
$show->field('sex');
$show->field('birthday');
$show->field('card_no');
$show->field('card_province_id');
$show->field('card_city_id');
$show->field('card_area_id');
$show->field('card_address');
$show->field('client_name');
$show->field('client_province_id');
$show->field('client_city_id');
$show->field('client_area_id');
$show->field('client_address');
$show->field('client_phone');
$show->field('nurse_lv');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new Oldman(), function (Form $form) {
$form->display('id');
$form->row(function (Form\Row $form) {
$form->divider('居住人');
});
$form->row(function (Form\Row $form) {
$form->width(6)->text('floor_name');
$form->width(6)->text('agreement_no');
});
$form->row(function (Form\Row $form) {
$form->width(6)->text('name')->required();
$form->width(3)->radio('sex')->options(['1'=>'男', '2'=>'女'])->required();
});
$form->row(function (Form\Row $form) {
$form->width(6)->text('card_no')->required();
$form->width(6)->date('birthday')->required();
});
$form->row(function (Form\Row $form) {
$form->width(3)->select('card_province_id')->required();
$form->width(3)->select('card_city_id')->required();
$form->width(3)->select('card_area_id')->required();
});
$form->row(function (Form\Row $form) {
$form->text('card_address')->required();
});
$form->row(function (Form\Row $form) {
$form->select('nurse_lv')->required();
});
$form->row(function (Form\Row $form) {
$form->divider('委托人');
});
$form->row(function (Form\Row $form) {
$form->width(6)->text('client_name')->required();
$form->width(6)->text('client_phone')->required();
});
$form->row(function (Form\Row $form) {
$form->width(3)->select('client_province_id')->required();
$form->width(3)->select('client_city_id')->required();
$form->width(3)->select('client_area_id')->required();
});
$form->row(function (Form\Row $form) {
$form->text('client_address')->required();
});
$form->display('created_at');
$form->display('updated_at');
});
}
}