Completed
Push — master ( 814073...4a1646 )
by Yaro
10:23 queued 02:16
created

Textarea::getListValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 7
cp 0.8571
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.0116
1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields;
4
5
use Illuminate\Http\Request;
6
use Yaro\Jarboe\Table\Fields\Traits\Clipboard;
7
use Yaro\Jarboe\Table\Fields\Traits\Inline;
8
use Yaro\Jarboe\Table\Fields\Traits\Nullable;
9
use Yaro\Jarboe\Table\Fields\Traits\Orderable;
10
use Yaro\Jarboe\Table\Fields\Traits\Placeholder;
11
use Yaro\Jarboe\Table\Fields\Traits\Tooltip;
12
use Yaro\Jarboe\Table\Fields\Traits\Translatable;
13
14
class Textarea extends AbstractField
15
{
16
    use Orderable;
17
    use Nullable;
18
    use Tooltip;
19
    use Clipboard;
20
    use Inline;
21
    use Translatable;
22
    use Placeholder;
23
24
    protected $rows = 3;
25
    protected $expandable = false;
26
    protected $resizable = false;
27
28
    public function rows(int $rows)
29
    {
30
        $this->rows = $rows;
31
32
        return $this;
33
    }
34
35
    public function getRowsNum()
36
    {
37
        return $this->rows;
38
    }
39
40
    public function expandable(bool $expandable = true)
41
    {
42
        $this->expandable = $expandable;
43
44
        return $this;
45
    }
46
47
    public function isExpandable()
48
    {
49
        return $this->expandable;
50
    }
51
52
    public function resizable(bool $resizable = true)
53
    {
54
        $this->resizable = $resizable;
55
56
        return $this;
57
    }
58
59
    public function isResizable()
60
    {
61
        return $this->resizable;
62
    }
63
64 View Code Duplication
    public function value(Request $request)
65
    {
66
        $value = parent::value($request);
67
        if (is_null($value) && $this->isNullable()) {
68
            return null;
69
        }
70
71
        return is_array($value) ? $value : (string) $value;
72
    }
73
74 1
    public function getListValue($model)
75
    {
76 1
        $template = 'list';
77 1
        if ($this->isTranslatable()) {
78
            $template .= '_translatable';
79
        }
80
81 1
        return view('jarboe::crud.fields.textarea.'. $template, [
82 1
            'model' => $model,
83 1
            'field' => $this,
84
        ]);
85
    }
86
87 1 View Code Duplication
    public function getEditFormValue($model)
88
    {
89 1
        $template = $this->isReadonly() ? 'readonly' : 'edit';
90
91 1
        return view('jarboe::crud.fields.textarea.'. $template, [
92 1
            'model' => $model,
93 1
            'field' => $this,
94
        ]);
95
    }
96
97 1
    public function getCreateFormValue()
98
    {
99 1
        return view('jarboe::crud.fields.textarea.create', [
100 1
            'field' => $this,
101
        ]);
102
    }
103
}
104