|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Boduch\Grid; |
|
4
|
|
|
|
|
5
|
|
|
use Collective\Html\HtmlBuilder; |
|
6
|
|
|
use Collective\Html\FormBuilder; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
use Illuminate\Contracts\Validation\Factory as ValidationFactory; |
|
9
|
|
|
use Illuminate\Contracts\View\Factory as ViewFactory; |
|
10
|
|
|
|
|
11
|
|
|
class GridHelper |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var Request |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $request; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var ViewFactory |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $view; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var ValidationFactory |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $validator; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var HtmlBuilder |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $htmlBuilder; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var FormBuilder |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $formBuilder; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param Request $request |
|
40
|
|
|
* @param ValidationFactory $validator |
|
41
|
|
|
* @param ViewFactory $view |
|
42
|
|
|
* @param HtmlBuilder $htmlBuilder |
|
43
|
|
|
* @param FormBuilder $formBuilder |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct( |
|
46
|
|
|
Request $request, |
|
|
|
|
|
|
47
|
|
|
ValidationFactory $validator, |
|
48
|
|
|
ViewFactory $view, |
|
49
|
|
|
HtmlBuilder $htmlBuilder, |
|
50
|
|
|
FormBuilder $formBuilder |
|
51
|
|
|
) { |
|
52
|
|
|
$this->request = $request; |
|
53
|
|
|
$this->view = $view; |
|
54
|
|
|
$this->validator = $validator; |
|
55
|
|
|
$this->htmlBuilder = $htmlBuilder; |
|
56
|
|
|
$this->formBuilder = $formBuilder; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return Request |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getRequest() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->request; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return ViewFactory |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getView() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->view; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return ValidationFactory |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getValidator() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->validator; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return HtmlBuilder |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getHtmlBuilder() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->htmlBuilder; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return FormBuilder |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getFormBuilder() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->formBuilder; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param $rules array |
|
101
|
|
|
* @return \Illuminate\Contracts\Validation\Validator |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getValidatorInstance($rules) |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->validator->make($this->request->all(), $rules); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Generate an html tag. |
|
110
|
|
|
* |
|
111
|
|
|
* @param string $tag |
|
112
|
|
|
* @param string $content |
|
113
|
|
|
* @param array $attributes |
|
114
|
|
|
* |
|
115
|
|
|
* @return \Illuminate\Support\HtmlString |
|
116
|
|
|
*/ |
|
117
|
|
|
public function tag($tag, $content, array $attributes = []) |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->htmlBuilder->tag($tag, $content, $attributes); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|