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