UserAddressController.php
2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\UserAddress;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class UserAddressController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new UserAddress(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->user_id()->width(70);
$grid->column('country');
$grid->column('first_name');
$grid->column('last_name');
$grid->column('address_line1');
$grid->column('address_line2');
$grid->column('city');
$grid->column('postal_code')->label('primary');
$grid->column('created_at');
$grid->column('updated_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
$filter->panel();
$filter->equal('id')->width(2);
$filter->equal('user_id')->width(2);
$filter->like('first_name')->width(2);
$filter->like('last_name')->width(2);
$filter->like('postal_code')->width(2);
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new UserAddress(), function (Show $show) {
$show->field('id');
$show->field('user_id');
$show->field('country');
$show->field('first_name');
$show->field('last_name');
$show->field('address_line1');
$show->field('address_line2');
$show->field('city');
$show->field('postal_code');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new UserAddress(), function (Form $form) {
$form->display('id');
$form->text('user_id');
$form->text('country');
$form->text('first_name');
$form->text('last_name');
$form->text('address_line1');
$form->text('address_line2');
$form->text('city');
$form->text('postal_code');
$form->display('created_at');
$form->display('updated_at');
});
}
}