getByProvinceRegionAndCityId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Yajra\Address\Repositories\Barangays;
4
5
use Yajra\Address\Entities\Barangay;
6
use Yajra\Address\Repositories\EloquentBaseRepository;
7
8
class BarangaysRepositoryEloquent extends EloquentBaseRepository implements BarangaysRepository
9
{
10
    /**
11
     * Get barangays by region, province and city ID.
12
     *
13
     * @param int $cityId
14
     * @return \Illuminate\Database\Eloquent\Collection
15
     */
16
    public function getByCity($cityId)
17
    {
18
        return $this->getModel()
0 ignored issues
show
Bug introduced by
The method orderBy() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean enforceOrderBy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
19
                    ->newQuery()
20
                    ->where('city_id', $cityId)
21
                    ->orderBy('name', 'asc')
22
                    ->get();
23
    }
24
25
    /**
26
     * Get repository model.
27
     *
28
     * @return \Illuminate\Database\Eloquent\Model
29
     */
30
    public function getModel()
31
    {
32
        $model = config('address.models.barangay', Barangay::class);
33
34
        return new $model;
35
    }
36
37
    /**
38
     * Get barangays by region, province and city ID.
39
     *
40
     * @param int $regionId
41
     * @param int $provinceId
42
     * @param int $cityId
43
     * @return \Illuminate\Database\Eloquent\Collection
44
     */
45
    public function getByProvinceRegionAndCityId($regionId, $provinceId, $cityId)
46
    {
47
        return $this->getModel()
0 ignored issues
show
Bug introduced by
The method orderBy() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean enforceOrderBy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
48
                    ->newQuery()
49
                    ->where('region_id', $regionId)
50
                    ->where('province_id', $provinceId)
51
                    ->where('city_id', $cityId)
52
                    ->orderBy('name', 'asc')
53
                    ->get();
54
    }
55
}
56