This repository was archived by the owner on Jan 24, 2024. It is now read-only.
File tree 7 files changed +22
-15
lines changed
7 files changed +22
-15
lines changed Original file line number Diff line number Diff line change 17
17
*
18
18
* @package Spiral\FAQ\Controllers
19
19
* @property \Spiral\Views\ViewsInterface $views
20
+ * @property \Spiral\Vault\Vault $vault
20
21
*/
21
22
class FAQController extends Controller
22
23
{
23
24
use GuardedTrait, TranslatorTrait;
24
25
25
26
const GUARD_NAMESPACE = 'vault.faq ' ;
26
27
27
- /** @var \Spiral\FAQ\Database\Sources\FAQSource */
28
+ /** @var \Spiral\FAQ\Database\Sources\FAQSource */
28
29
private $ source ;
29
30
30
31
/**
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ class FAQ extends Record
24
24
'id ' => 'primary ' ,
25
25
'status ' => FAQStatus::class,
26
26
'question ' => 'string(255) ' ,
27
- 'answer ' => 'text '
27
+ 'answer ' => 'text ' ,
28
+ 'order ' => 'float ' ,
28
29
];
29
30
30
31
/**
@@ -37,7 +38,8 @@ class FAQ extends Record
37
38
*/
38
39
const FILLABLE = [
39
40
'question ' ,
40
- 'answer '
41
+ 'answer ' ,
42
+ 'order '
41
43
];
42
44
43
45
const DEFAULTS = [];
Original file line number Diff line number Diff line change 10
10
*
11
11
* @package Spiral\FAQ\Requests
12
12
* @property string $status
13
+ * @property float $order
13
14
*/
14
15
class FAQRequest extends RequestFilter
15
16
{
@@ -20,6 +21,7 @@ class FAQRequest extends RequestFilter
20
21
'question ' => 'data:question ' ,
21
22
'answer ' => 'data:answer ' ,
22
23
'status ' => 'data:status ' ,
24
+ 'order ' => 'data:order ' ,
23
25
];
24
26
25
27
const VALIDATES = [
@@ -42,5 +44,6 @@ class FAQRequest extends RequestFilter
42
44
const SETTERS = [
43
45
'question ' => 'trim ' ,
44
46
'answer ' => 'trim ' ,
47
+ 'order ' => 'floatval ' ,
45
48
];
46
49
}
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ public function getFAQ(RecordSelector $selector): Listing
40
40
41
41
$ listing ->addSorter ('id ' , new BinarySorter ('id ' ));
42
42
$ listing ->addSorter ('question ' , new BinarySorter ('question ' ));
43
+ $ listing ->addSorter ('order ' , new BinarySorter ('order ' ));
43
44
44
45
$ listing ->addFilter (
45
46
'status ' ,
Original file line number Diff line number Diff line change 15
15
<div class="row">
16
16
<div class="col s12 m8">
17
17
<vault:form action="<?= vault ()->uri ('faq:create ' ) ?> ">
18
+ <form:input label="[[Question:]]" name="question"/>
19
+ <form:textarea label="[[Answer:]]" name="answer" rows="20"/>
20
+
18
21
<div class="row">
19
22
<div class="col s12 m12">
20
- <form:input label="[[Question :]]" name="question "/>
23
+ <form:select label="[[Status :]]" name="status" values=" <?= $ statuses -> labels ( true ) ?> "/>
21
24
</div>
22
- </div>
23
- <div class="row">
24
25
<div class="col s12 m12">
25
- <form:textarea label="[[Answer :]]" name="answer" rows="20 "/>
26
+ <form:input label="[[Order :]]" name="order "/>
26
27
</div>
27
28
</div>
28
- <form:select label="[[Status:]]" name="status" values="<?= $ statuses ->labels (true ) ?> "/>
29
29
30
30
<div class="right-align">
31
31
<input type="submit" value="[[CREATE]]" class="btn waves-effect waves-light"/>
Original file line number Diff line number Diff line change 14
14
<div class="row">
15
15
<div class="col s12 m8">
16
16
<vault:form action="<?= vault ()->uri ('faq:update ' , ['id ' => $ entity ->primaryKey ()]) ?> ">
17
+ <form:input label="[[Question:]]" name="question" value="<?= e ($ entity ->question ) ?> "/>
18
+ <form:textarea label="[[Answer:]]" name="answer" rows="20" value="<?= $ entity ->answer ?> "/>
19
+
17
20
<div class="row">
18
21
<div class="col s12 m12">
19
- <form:input label="[[Question :]]" name="question" value ="<?= e ( $ entity ->question ) ?> "/>
22
+ <form:select label="[[Status :]]" name="status" values ="<?= $ statuses -> labels ( true ) ?> " value=" <?= $ entity ->status ?> "/>
20
23
</div>
21
- </div>
22
- <div class="row">
23
24
<div class="col s12 m12">
24
- <form:textarea label="[[Answer :]]" name="answer" rows="20" value="<?= $ entity ->answer ?> "/>
25
+ <form:input label="[[Order :]]" name="order" value="<?= $ entity ->order ?> "/>
25
26
</div>
26
27
</div>
27
- <form:select label="[[Status:]]" name="status" values="<?= $ statuses ->labels (true ) ?> " value="<?= $ entity ->status ?> "/>
28
-
29
28
<div class="right-align">
30
29
<input type="submit" value="[[UPDATE]]" class="btn waves-effect waves-light"/>
31
30
</div>
Original file line number Diff line number Diff line change 40
40
41
41
<vault:listing listing="<?= $ listing ?> " as="entity" color="" class="striped">
42
42
43
- <grid:cell label="[[Id:]]" value="<?= e ( $ entity ->id ) ?> " sorter="id"/>
43
+ <grid:cell label="[[Id:]]" value="<?= $ entity ->id ?> " sorter="id"/>
44
44
<grid:cell label="[[Question:]]" sorter="question">
45
45
<span title="<?= e ($ entity ->question ) ?> "><?= \Spiral \Support \Strings::shorter (e ($ entity ->question ), 50 ) ?> </span>
46
46
</grid:cell>
47
47
<grid:cell label="[[Answer:]]">
48
48
<span title="<?= e ($ entity ->answer ) ?> "><?= \Spiral \Support \Strings::shorter (e ($ entity ->answer ), 100 ) ?> </span>
49
49
</grid:cell>
50
+ <grid:cell label="[[Order:]]" value="<?= $ entity ->order ?> " sorter="order"/>
50
51
<grid:cell class="right-align">
51
52
<vault:uri target="faq:edit" icon="edit" options="<?= ['id ' => $ entity ->primaryKey ()] ?> " class="waves-effect btn-flat"/>
52
53
</grid:cell>
You can’t perform that action at this time.
0 commit comments