Completed
Push — master ( 7af38e...06d7c0 )
by Arjay
01:24
created

Select2::placeholder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Yajra\DataTables\Html\Editor\Fields;
4
5
/**
6
 * @see https://editor.datatables.net/plug-ins/field-type/editor.select2
7
 */
8
class Select2 extends Select
9
{
10
    protected $type = 'select2';
11
12
    /**
13
     * @param bool $state
14
     * @return $this
15
     */
16
    public function allowClear($state = true)
17
    {
18
        $this->attributes['opts']['allowClear'] = $state;
19
20
        return $this;
21
    }
22
23
    /**
24
     * @param string $text
25
     * @param string|null $id
26
     * @return $this
27
     */
28
    public function placeholder($text = '', $id = null)
29
    {
30
        $this->attributes['opts']['placeholder'] = [
31
            'id'   => $id,
32
            'text' => $text,
33
        ];
34
35
        return $this;
36
    }
37
}
38