Passed
Pull Request — master (#1022)
by Diego
03:15
created

InputDate::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\View\Components\Form;
4
5
class InputDate extends InputGroupComponent
6
{
7
    /**
8
     * The default set of icons for the Tempus Dominus plugin configuration.
9
     *
10
     * @var array
11
     */
12
    protected $icons = [
13
        'time'     => 'fas fa-clock',
14
        'date'     => 'fas fa-calendar-alt',
15
        'up'       => 'fas fa-arrow-up',
16
        'down'     => 'fas fa-arrow-down',
17
        'previous' => 'fas fa-chevron-left',
18
        'next'     => 'fas fa-chevron-right',
19
        'today'    => 'fas fa-calendar-check-o',
20
        'clear'    => 'fas fa-trash',
21
        'close'    => 'fas fa-times',
22
    ];
23
24
    /**
25
     * The default set of buttons for the Tempus Dominus plugin configuration.
26
     *
27
     * @var array
28
     */
29
    protected $buttons = [
30
        'showClose' => true,
31
    ];
32
33
    /**
34
     * The Tempus Dominus plugin configuration parameters. Array with
35
     * key => value pairs, where the key should be an existing configuration
36
     * property of the plugin.
37
     *
38
     * @var array
39
     */
40
    public $config;
41
42
    /**
43
     * Create a new component instance.
44
     * Note this component requires the 'Tempus Dominus' plugin.
45
     *
46
     * @return void
47
     */
48 2
    public function __construct(
49
        $name, $id = null, $label = null, $igroupSize = null, $labelClass = null,
50
        $fgroupClass = null, $igroupClass = null, $disableFeedback = null,
51
        $errorKey = null, $config = []
52
    ) {
53 2
        parent::__construct(
54 2
            $name, $id, $label, $igroupSize, $labelClass, $fgroupClass,
55
            $igroupClass, $disableFeedback, $errorKey
56
        );
57
58 2
        $this->config = is_array($config) ? $config : [];
59
60
        // Setup the default plugin icons option.
61
62 2
        $this->config['icons'] = $this->config['icons'] ?? $this->icons;
63
64
        // Setup the default plugin buttons option.
65
66 2
        $this->config['buttons'] = $this->config['buttons'] ?? $this->buttons;
67 2
    }
68
69
    /**
70
     * Make the class attribute for the input group item.
71
     *
72
     * @return string
73
     */
74 1
    public function makeItemClass()
75
    {
76 1
        $classes = ['form-control', 'datetimepicker'];
77
78 1
        if ($this->isInvalid() && ! isset($this->disableFeedback)) {
79 1
            $classes[] = 'is-invalid';
80
        }
81
82 1
        return implode(' ', $classes);
83
    }
84
85
    /**
86
     * Get the view / contents that represent the component.
87
     *
88
     * @return \Illuminate\View\View|string
89
     */
90 1
    public function render()
91
    {
92 1
        return view('adminlte::components.form.input-date');
93
    }
94
}
95