Completed
Push — master ( d84b0e...706b03 )
by
unknown
05:32
created

Label::cards()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace BBSLab\NovaTranslation\Resources;
4
5
use BBSLab\NovaTranslation\Models\Label as Model;
6
use BBSLab\NovaTranslation\NovaTranslationServiceProvider;
7
use Illuminate\Http\Request;
8
use Laravel\Nova\Fields\ID;
9
use Laravel\Nova\Fields\Select;
10
use Laravel\Nova\Fields\Text;
11
use Laravel\Nova\Fields\Textarea;
12
use Laravel\Nova\Resource;
13
14
class Label extends TranslatableResource
15
{
16
    /**
17
     * The model the resource corresponds to.
18
     *
19
     * @var string
20
     */
21
    public static $model = 'BBSLab\\NovaTranslation\\Models\\Label';
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public static $title = 'key';
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public static $search = [
32
        'key',
33
        'value',
34
    ];
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public static $group = null;
40
41
    // @TODO... Refactor
42
    protected function singleIsoFields(Request $request)
43
    {
44
        return [
45
            ID::make()->sortable(),
46
47
            Select::make('Type', 'type')
48
                ->sortable()
49
                ->options([
50
                    Model::TYPE_TEXT => trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.types.'.Model::TYPE_TEXT),
51
                    Model::TYPE_UPLOAD => trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.types.'.Model::TYPE_UPLOAD),
52
                ])
53
                ->displayUsingLabels(),
54
55
            Text::make('Key', 'key')
56
                ->sortable()
57
                ->rules('required'),
58
59
            Textarea::make('Value', 'value')
60
                ->hideFromIndex(),
61
        ];
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function fields(Request $request)
68
    {
69
        // return $this->singleIsoFields($request);
70
71
        return $this->translations($request, $this->singleIsoFields($request));
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function cards(Request $request)
78
    {
79
        return [];
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function filters(Request $request)
86
    {
87
        return [];
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function lenses(Request $request)
94
    {
95
        return [];
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    public function actions(Request $request)
102
    {
103
        return [];
104
    }
105
}
106