-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPagesConfig.php
More file actions
217 lines (190 loc) · 5.18 KB
/
Copy pathPagesConfig.php
File metadata and controls
217 lines (190 loc) · 5.18 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
namespace Litstack\Pages;
use Ignite\Crud\Config\CrudConfig;
use Ignite\Crud\CrudIndex;
use Ignite\Crud\CrudShow;
use Ignite\Crud\Fields\Block\Repeatables;
use Illuminate\Support\Str;
use Litstack\Pages\Models\Page;
abstract class PagesConfig extends CrudConfig
{
/**
* Pages model class.
*
* @var string
*/
public $model = Page::class;
/**
* Application route prefix.
*
* @return string
*/
abstract public function appRoutePrefix(string $locale = null);
/**
* Make repeatbles that should be available for pages.
*
* @param Repeatables $rep
* @return void
*/
abstract public function repeatables(Repeatables $rep);
/**
* Page route prefix in the listack backend.
*
* @return string
*/
public function litstackRoutePrefix()
{
return 'pages/'.Str::slug($this->collection());
}
/**
* Page route prefix in the litstack backend.
*
* @return string
*/
public function routePrefix()
{
return $this->litstackRoutePrefix();
}
/**
* Determine if pages are translatable.
*
* @return bool
*/
public function translatable()
{
return lit()->isAppTranslatable();
}
/**
* Get pages collection name.
*
* @return string
*/
public function collection()
{
return Str::snake(str_replace('Config', '', class_basename(static::class)));
}
/**
* Build index table.
*
* @param \Ignite\Crud\CrudIndex $table
* @return void
*/
public function index(CrudIndex $container)
{
$container->table(fn ($table) => $this->indexTableColumns($table))
->search($this->getTitleColumnName());
}
/**
* Build index table columnds.
*
* @param \Ignite\Vue\Crud\CrudTable $table
* @return void
*/
public function indexTableColumns($table)
{
$this->makeTitleColumns($table);
$table->col('Url '.fa('external-link-alt'))
->value('<a href="{uri}" target="_blank">{uri}</a>')
->link(false);
}
/**
* Make title column.
*
* @param \Ignite\Vue\Crud\CrudTable $table
* @return void
*/
protected function makeTitleColumns($table)
{
$table->col('Title')
->value('{'.$this->getTitleColumnName().'}')
->sortBy($this->getTitleColumnName());
}
/**
* Get title column name.
*
* @return string
*/
protected function getTitleColumnName()
{
return $this->translatable() ? 't_title' : 'title';
}
/**
* Get title column name.
*
* @return string
*/
protected function getSlugColumnName()
{
return $this->translatable() ? 't_slug' : 'slug';
}
/**
* Setup create and edit form.
*
* @param \Ignite\Crud\CrudShow $page
* @return void
*/
public function show(CrudShow $page)
{
$page->card(function ($form) {
$form->input($this->getTitleColumnName())
->translatable($this->translatable())
->creationRules('required')
->rules('min:2')
->title('Title')
->width(8)
->hint('Seitentitel in Litstack / Aus dem Titel wird auch der Slug für die URL generiert');
$form->modal('change_slug')
->title('Slug')
->variant('primary')
->preview($this->routePrefix()."/<b>{".$this->getSlugColumnName()."}</b>")
->name('Change Slug')
->form(function ($modal) {
$modal->input($this->getSlugColumnName())
->width(12)
->title('Slug');
})->width(4);
$form->image('page_image')
->title('Page-Image')
->hint('Kann z.B. als Vorschaubild oder Header-Bild eingesetzt werden.')
->maxFiles(1)
->expand()
->width(6);
$form->textarea('page_excerpt')
->title('Page-Excerpt')
->translatable($this->translatable())
->hint('Vorschautext z.B. für Übersichtsseiten')
->width(6);
$this->prependForm($form);
});
$page->card(function ($form) {
$form->input('h1')
->translatable($this->translatable())
->hint('Kurz, aber aussagekräftig (5 Wörter oder weniger), Thematik der Headline entspricht der Thematik im Content')
->title('H1');
$this->makeContentBlock($form);
});
$this->appendForm($page);
$page->meta();
}
public function prependForm(CrudShow $form)
{
//
}
public function appendForm(CrudShow $page)
{
}
/**
* Make content block.
*
* @param CrudShow $form
* @return void
*/
protected function makeContentBlock($form)
{
$form->block('content')
->title('Content')
->repeatables(function ($rep) {
$this->repeatables($rep);
});
}
}