1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\PanelTraits; |
4
|
|
|
|
5
|
|
|
trait Views |
6
|
|
|
{ |
7
|
|
|
protected $createView = 'crud::create'; |
8
|
|
|
|
9
|
|
|
protected $editView = 'crud::edit'; |
10
|
|
|
|
11
|
|
|
protected $showView = 'crud::show'; |
12
|
|
|
|
13
|
|
|
protected $detailsRowView = 'crud::details_row'; |
14
|
|
|
|
15
|
|
|
protected $revisionsView = 'crud::revisions'; |
16
|
|
|
|
17
|
|
|
protected $revisionsTimelineView = 'crud::inc.revision_timeline'; |
18
|
|
|
|
19
|
|
|
protected $reorderView = 'crud::reorder'; |
20
|
|
|
|
21
|
|
|
protected $listView = 'crud::list'; |
22
|
|
|
|
23
|
|
|
protected $createContentClass; |
24
|
|
|
|
25
|
|
|
protected $editContentClass; |
26
|
|
|
|
27
|
|
|
protected $listContentClass; |
28
|
|
|
|
29
|
|
|
// ------- |
30
|
|
|
// CREATE |
31
|
|
|
// ------- |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Sets the create template. |
35
|
|
|
* @param string $view name of the template file |
36
|
|
|
* @return string $view name of the template file |
37
|
|
|
*/ |
38
|
|
|
public function setCreateView($view) |
39
|
|
|
{ |
40
|
|
|
$this->createView = $view; |
41
|
|
|
|
42
|
|
|
return $this->createView; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Gets the create template. |
47
|
|
|
* @return string name of the template file |
48
|
|
|
*/ |
49
|
|
|
public function getCreateView() |
50
|
|
|
{ |
51
|
|
|
return $this->createView; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Sets the create content class. |
56
|
|
|
* @param string $createContentClass content class |
57
|
|
|
*/ |
58
|
|
|
public function setCreateContentClass(string $createContentClass) |
59
|
|
|
{ |
60
|
|
|
$this->createContentClass = $createContentClass; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Gets the create content class. |
65
|
|
|
* @return string content class for create view |
66
|
|
|
*/ |
67
|
|
|
public function getCreateContentClass() |
68
|
|
|
{ |
69
|
|
|
return $this->createContentClass ?? config('backpack.crud.create_content_class', 'col-md-8 col-md-offset-2'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
// ------- |
73
|
|
|
// READ |
74
|
|
|
// ------- |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Sets the list template. |
78
|
|
|
* @param string $view name of the template file |
79
|
|
|
* @return string $view name of the template file |
80
|
|
|
*/ |
81
|
|
|
public function setListView($view) |
82
|
|
|
{ |
83
|
|
|
$this->listView = $view; |
84
|
|
|
|
85
|
|
|
return $this->listView; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Gets the list template. |
90
|
|
|
* @return string name of the template file |
91
|
|
|
*/ |
92
|
|
|
public function getListView() |
93
|
|
|
{ |
94
|
|
|
return $this->listView; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Sets the list content class. |
99
|
|
|
* @param string $listContentClass content class |
100
|
|
|
*/ |
101
|
|
|
public function setListContentClass(string $listContentClass) |
102
|
|
|
{ |
103
|
|
|
$this->listContentClass = $listContentClass; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Gets the list content class. |
108
|
|
|
* @return string content class for list view |
109
|
|
|
*/ |
110
|
|
|
public function getListContentClass() |
111
|
|
|
{ |
112
|
|
|
return $this->listContentClass ?? config('backpack.crud.list_content_class', 'col-md-12');; |
|
|
|
|
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Sets the details row template. |
117
|
|
|
* @param string $view name of the template file |
118
|
|
|
* @return string $view name of the template file |
119
|
|
|
*/ |
120
|
|
|
public function setDetailsRowView($view) |
121
|
|
|
{ |
122
|
|
|
$this->detailsRowView = $view; |
123
|
|
|
|
124
|
|
|
return $this->detailsRowView; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Gets the details row template. |
129
|
|
|
* @return string name of the template file |
130
|
|
|
*/ |
131
|
|
|
public function getDetailsRowView() |
132
|
|
|
{ |
133
|
|
|
return $this->detailsRowView; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Sets the show template. |
138
|
|
|
* @param string $view name of the template file |
139
|
|
|
* @return string $view name of the template file |
140
|
|
|
*/ |
141
|
|
|
public function setShowView($view) |
142
|
|
|
{ |
143
|
|
|
$this->showView = $view; |
144
|
|
|
|
145
|
|
|
return $this->showView; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Gets the show template. |
150
|
|
|
* @return string name of the template file |
151
|
|
|
*/ |
152
|
|
|
public function getShowView() |
153
|
|
|
{ |
154
|
|
|
return $this->showView; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
// ------- |
158
|
|
|
// UPDATE |
159
|
|
|
// ------- |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Sets the edit template. |
163
|
|
|
* @param string $view name of the template file |
164
|
|
|
* @return string $view name of the template file |
165
|
|
|
*/ |
166
|
|
|
public function setEditView($view) |
167
|
|
|
{ |
168
|
|
|
$this->editView = $view; |
169
|
|
|
|
170
|
|
|
return $this->editView; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Gets the edit template. |
175
|
|
|
* @return string name of the template file |
176
|
|
|
*/ |
177
|
|
|
public function getEditView() |
178
|
|
|
{ |
179
|
|
|
return $this->editView; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Sets the edit content class. |
184
|
|
|
* @param string $editContentClass content class |
185
|
|
|
*/ |
186
|
|
|
public function setEditContentClass(string $editContentClass) |
187
|
|
|
{ |
188
|
|
|
$this->editContentClass = $editContentClass; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Gets the edit content class. |
193
|
|
|
* @return string content class for edit view |
194
|
|
|
*/ |
195
|
|
|
public function getEditContentClass() |
196
|
|
|
{ |
197
|
|
|
return $this->editContentClass ?? config('backpack.crud.edit_content_class', 'col-md-8 col-md-offset-2'); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Sets the reorder template. |
202
|
|
|
* @param string $view name of the template file |
203
|
|
|
* @return string $view name of the template file |
204
|
|
|
*/ |
205
|
|
|
public function setReorderView($view) |
206
|
|
|
{ |
207
|
|
|
$this->reorderView = $view; |
208
|
|
|
|
209
|
|
|
return $this->reorderView; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Gets the reorder template. |
214
|
|
|
* @return string name of the template file |
215
|
|
|
*/ |
216
|
|
|
public function getReorderView() |
217
|
|
|
{ |
218
|
|
|
return $this->reorderView; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Sets the revision template. |
223
|
|
|
* @param string $view name of the template file |
224
|
|
|
* @return string $view name of the template file |
225
|
|
|
*/ |
226
|
|
|
public function setRevisionsView($view) |
227
|
|
|
{ |
228
|
|
|
$this->revisionsView = $view; |
229
|
|
|
|
230
|
|
|
return $this->revisionsView; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Sets the revision template. |
235
|
|
|
* @param string $view name of the template file |
236
|
|
|
* @return string $view name of the template file |
237
|
|
|
*/ |
238
|
|
|
public function setRevisionsTimelineView($view) |
239
|
|
|
{ |
240
|
|
|
$this->revisionsTimelineView = $view; |
241
|
|
|
|
242
|
|
|
return $this->revisionsTimelineView; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Gets the revisions template. |
247
|
|
|
* @return string name of the template file |
248
|
|
|
*/ |
249
|
|
|
public function getRevisionsView() |
250
|
|
|
{ |
251
|
|
|
return $this->revisionsView; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* Gets the revisions template. |
256
|
|
|
* @return string name of the template file |
257
|
|
|
*/ |
258
|
|
|
public function getRevisionsTimelineView() |
259
|
|
|
{ |
260
|
|
|
return $this->revisionsTimelineView; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
// ------- |
264
|
|
|
// ALIASES |
265
|
|
|
// ------- |
266
|
|
|
|
267
|
|
|
public function getPreviewView() |
268
|
|
|
{ |
269
|
|
|
return $this->getShowView(); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
public function setPreviewView($view) |
273
|
|
|
{ |
274
|
|
|
return $this->setShowView($view); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function getUpdateView() |
278
|
|
|
{ |
279
|
|
|
return $this->getEditView(); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
public function setUpdateView($view) |
283
|
|
|
{ |
284
|
|
|
return $this->setEditView($view); |
285
|
|
|
} |
286
|
|
|
} |
287
|
|
|
|
Let’s take a look at an example: