Completed
Push — master ( 6943ef...15a38e )
by Song
02:31
created

QuickSearch::placeholder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid\Tools;
4
5
use Encore\Admin\Grid\Concerns\HasQuickSearch;
6
use Illuminate\Support\Arr;
7
8
class QuickSearch extends AbstractTool
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $view = 'admin::grid.quick-search';
14
15
    /**
16
     * @var string
17
     */
18
    protected $placeholder;
19
20
    /**
21
     * Set placeholder.
22
     *
23
     * @param string $text
24
     *
25
     * @return $this
26
     */
27
    public function placeholder($text = '')
28
    {
29
        $this->placeholder = $text;
30
31
        return $this;
32
    }
33
34
    /**
35
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
36
     */
37
    public function render()
38
    {
39
        $query = request()->query();
40
41
        Arr::forget($query, HasQuickSearch::$searchKey);
42
43
        $vars = [
44
            'action'      => request()->url().'?'.http_build_query($query),
45
            'key'         => HasQuickSearch::$searchKey,
46
            'value'       => request(HasQuickSearch::$searchKey),
47
            'placeholder' => $this->placeholder,
48
        ];
49
50
        return view($this->view, $vars);
0 ignored issues
show
Bug Compatibility introduced by
The expression view($this->view, $vars); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 50 which is incompatible with the return type declared by the interface Illuminate\Contracts\Support\Renderable::render of type string.
Loading history...
51
    }
52
}
53