Completed
Push — master ( d44234...ddcd57 )
by Adam
02:30
created

Search::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
namespace BestServedCold\LaravelZendSearch\Laravel;
4
5
use BestServedCold\LaravelZendSearch\Lucene\Query;
6
use BestServedCold\LaravelZendSearch\Lucene\Search as LuceneSearch;
7
8
/**
9
 * Class Search
10
 * @package BestServedCold\LaravelZendSearch\Laravel
11
 */
12
class Search extends LuceneSearch
13
{
14
    use EloquentTrait;
15
16
    /**
17
     * Search constructor.
18
     * @param Index $index
19
     * @param Query $query
20
     */
21 4
    public function __construct(Index $index, Query $query)
22
    {
23 4
        parent::__construct($index, $query);
24 4
        $this->path(config('search.index.path'));
25 4
    }
26
27
    /**
28
     * @return mixed
29
     */
30 1
    public function get()
31
    {
32 1
        return $this->model->whereIn(
33 1
            $this->key,
34 1
            $this->hits()
35 1
        )->get();
36
    }
37
38
    /**
39
     * @param $id
40
     * @return $this
41
     */
42 1
    public function findId($id)
43
    {
44 1
        $this->where($id, 'xref_id');
45 1
        return $this;
46
    }
47
48
    /**
49
     * @return mixed
50
     */
51 1
    public function hits()
52
    {
53 1
        $this->where($this->uid, 'uid');
54 1
        return parent::hits();
55
    }
56
57
    /**
58
     * @param $string
59
     * @todo  This needs to be a find all with all the search attributes.
60
     * @return $this
61
     */
62 1
    public function find($string)
63
    {
64 1
        $this->where($string);
65 1
        return $this;
66
    }
67
}
68
69