SearchPane::name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Yajra\DataTables\Html;
4
5
use Illuminate\Support\Fluent;
6
use Illuminate\Contracts\Support\Arrayable;
7
use Yajra\DataTables\Html\Editor\Fields\Options;
8
9
class SearchPane extends Fluent
10
{
11
    /**
12
     * @param array $options
13
     * @return static
14
     */
15
    public static function make(array $options = [])
16
    {
17
        return new static($options);
18
    }
19
20
    /**
21
     * @param bool $value
22
     * @return static
23
     * @see https://datatables.net/reference/option/searchPanes.cascadePanes
24
     */
25
    public function cascadePanes($value = true)
26
    {
27
        $this->attributes['cascadePanes'] = $value;
28
29
        return $this;
30
    }
31
32
    /**
33
     * @param bool $value
34
     * @return static
35
     * @see https://datatables.net/reference/option/searchPanes.clear
36
     */
37
    public function clear($value = true)
38
    {
39
        $this->attributes['clear'] = $value;
40
41
        return $this;
42
    }
43
44
    /**
45
     * @param array $value
46
     * @return static
47
     * @see https://datatables.net/reference/option/searchPanes.columns
48
     */
49
    public function columns(array $value = [])
50
    {
51
        $this->attributes['columns'] = $value;
52
53
        return $this;
54
    }
55
56
    /**
57
     * @param bool $value
58
     * @return static
59
     * @see https://datatables.net/reference/option/searchPanes.controls
60
     */
61
    public function controls($value = true)
62
    {
63
        $this->attributes['controls'] = $value;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @param array $value
70
     * @return static
71
     * @see https://datatables.net/reference/option/searchPanes.dtOpts
72
     * @see https://datatables.net/reference/option/columns.searchPanes.dtOpts
73
     */
74
    public function dtOpts(array $value = [])
75
    {
76
        $this->attributes['dtOpts'] = $value;
77
78
        return $this;
79
    }
80
81
    /**
82
     * @param mixed $value
83
     * @return static
84
     * @see https://datatables.net/reference/option/searchPanes.emptyMessage
85
     */
86
    public function emptyMessage($value)
87
    {
88
        $this->attributes['emptyMessage'] = $value;
89
90
        return $this;
91
    }
92
93
    /**
94
     * @param mixed $value
95
     * @return static
96
     * @see https://datatables.net/reference/option/searchPanes.filterChanged
97
     */
98
    public function filterChanged($value)
99
    {
100
        $this->attributes['filterChanged'] = $value;
101
102
        return $this;
103
    }
104
105
    /**
106
     * @param bool $value
107
     * @return static
108
     * @see https://datatables.net/reference/option/searchPanes.hideCount
109
     */
110
    public function hideCount($value = true)
111
    {
112
        $this->attributes['hideCount'] = $value;
113
114
        return $this;
115
    }
116
117
    /**
118
     * @param mixed $value
119
     * @return static
120
     * @see https://datatables.net/reference/option/searchPanes.layout
121
     */
122
    public function layout($value)
123
    {
124
        $this->attributes['layout'] = $value;
125
126
        return $this;
127
    }
128
129
    /**
130
     * @param mixed $value
131
     * @return static
132
     * @see https://datatables.net/reference/option/searchPanes.order
133
     */
134
    public function order($value)
135
    {
136
        $this->attributes['order'] = $value;
137
138
        return $this;
139
    }
140
141
    /**
142
     * @param boolean $value
143
     * @return static
144
     * @see https://datatables.net/reference/option/searchPanes.orderable
145
     */
146
    public function orderable($value = true)
147
    {
148
        $this->attributes['orderable'] = $value;
149
150
        return $this;
151
    }
152
153
    /**
154
     * @param array $value
155
     * @return static
156
     * @see https://datatables.net/reference/option/searchPanes.panes
157
     */
158
    public function panes(array $value)
159
    {
160
        $panes = collect($value)->map(function ($pane) {
161
            if ($pane instanceof Arrayable) {
162
                return $pane->toArray();
163
            }
164
165
            return $pane;
166
        })->toArray();
167
168
        $this->attributes['panes'] = $panes;
169
170
        return $this;
171
    }
172
173
    /**
174
     * @param mixed $value
175
     * @return static
176
     * @see https://datatables.net/reference/option/searchPanes.threshold
177
     */
178
    public function threshold($value)
179
    {
180
        $this->attributes['threshold'] = $value;
181
182
        return $this;
183
    }
184
185
    /**
186
     * @param boolean $value
187
     * @return static
188
     * @see https://datatables.net/reference/option/searchPanes.viewTotal
189
     */
190
    public function viewTotal($value = true)
191
    {
192
        $this->attributes['viewTotal'] = $value;
193
194
        return $this;
195
    }
196
197
    /**
198
     * @param boolean $value
199
     * @return static
200
     * @see https://datatables.net/reference/option/searchPanes.viewTotal
201
     */
202
    public function hideTotal($value = true)
203
    {
204
        $this->attributes['viewTotal'] = ! $value;
205
206
        return $this;
207
    }
208
209
    /**
210
     * Get options from a model.
211
     *
212
     * @param mixed $model
213
     * @param string $value
214
     * @param string $key
215
     * @return $this
216
     */
217
    public function modelOptions($model, $value, $key = 'id')
218
    {
219
        return $this->options(
220
            Options::model($model, $value, $key)
221
        );
222
    }
223
224
    /**
225
     * @param mixed $value
226
     * @return static
227
     * @see https://datatables.net/reference/option/columns.searchPanes.options
228
     */
229 View Code Duplication
    public function options($value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
230
    {
231
        if ($value instanceof Arrayable) {
232
            $value = $value->toArray();
233
        }
234
235
        $this->attributes['options'] = $value;
236
237
        return $this;
238
    }
239
240
    /**
241
     * Get options from a table.
242
     *
243
     * @param mixed $table
244
     * @param string $value
245
     * @param string $key
246
     * @param \Closure $whereCallback
247
     * @param string|null $key
248
     * @return $this
249
     */
250
    public function tableOptions($table, $value, $key = 'id', \Closure $whereCallback = null, $connection = null)
251
    {
252
        return $this->options(
253
            Options::table($table, $value, $key, $whereCallback, $connection)
254
        );
255
    }
256
257
    /**
258
     * @param mixed $value
259
     * @return static
260
     * @see https://datatables.net/reference/option/columns.searchPanes.className
261
     */
262
    public function className($value)
263
    {
264
        $this->attributes['className'] = $value;
265
266
        return $this;
267
    }
268
269
    /**
270
     * @param mixed $value
271
     * @return static
272
     * @see https://datatables.net/reference/option/searchPanes.panes.header
273
     */
274
    public function header($value)
275
    {
276
        $this->attributes['header'] = $value;
277
278
        return $this;
279
    }
280
281
    /**
282
     * @param bool $value
283
     * @return static
284
     * @see https://datatables.net/reference/option/columns.searchPanes.show
285
     */
286
    public function show($value = true)
287
    {
288
        $this->attributes['show'] = $value;
289
290
        return $this;
291
    }
292
293
    /**
294
     * @param mixed $value
295
     * @return static
296
     * @see https://datatables.net/reference/option/columns.searchPanes.name
297
     */
298
    public function name($value)
299
    {
300
        $this->attributes['name'] = $value;
301
302
        return $this;
303
    }
304
305
    /**
306
     * @param mixed $value
307
     * @return static
308
     * @see https://datatables.net/reference/option/columns.searchPanes.orthogonal
309
     */
310
    public function orthogonal($value)
311
    {
312
        $this->attributes['orthogonal'] = $value;
313
314
        return $this;
315
    }
316
}
317