DatastoreRepository::paginateAccepted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 5
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Phpsa\Datastore\Repositories;
4
5
6
use App\Repositories\BaseRepository;
0 ignored issues
show
Bug introduced by
The type App\Repositories\BaseRepository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Phpsa\Datastore\Models\Datastore as DatastoreModel;
8
use Illuminate\Database\Eloquent\Collection;
9
use Phpsa\Datastore\Datastore;
10
use Phpsa\Datastore\Models\DatastoreDatastore;
11
use Phpsa\Datastore\Repositories\DatastoreDatastoreRepository;
12
/**
13
 * Class PermissionRepository.
14
 */
15
class DatastoreRepository extends BaseRepository
16
{
17
    /**
18
     * @return string
19
     */
20
    public function model()
21
    {
22
        return DatastoreModel::class;
23
	}
24
25
	public function paginateAssets($assetData, $limit = 25, $pageName = 'page', $page = null){
26
		$this->where('type', $assetData['class']);
27
		return $this->paginate($limit, ['*'], $pageName, $page);
28
29
	}
30
31
32
	    /**
33
     * @param int    $limit
34
     * @param array  $columns
35
     * @param string $pageName
36
     * @param null   $page
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $page is correct as it would always require null to be passed?
Loading history...
37
     *
38
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
39
     */
40
    public function paginate($limit = 25, array $columns = ['*'], $pageName = 'page', $page = null)
41
    {
42
        $this->newQuery()->eagerLoad()->setClauses()->setScopes();
43
44
        $models = $this->query->paginate($limit, $columns, $pageName, $page);
45
46
        $this->unsetClauses();
47
48
        return $models;
49
	}
50
51
52
	public function paginateAccepted($datastore_id, $status = NULL, $limit = 25, $pageName = 'page', $page = null){
53
		$ds2 = new DatastoreDatastoreRepository();
54
		return $ds2->paginateAccepted($datastore_id, $status, $limit, $pageName, $page);
55
	}
56
57
	public function paginateSearchProp($property, $property_value, $parent_type, $parent_status = NULL, $limit = 25, $pageName = 'page', $page = null){
58
59
		if($parent_status){
60
			$this->where('status', $published_status);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $published_status seems to be never defined.
Loading history...
61
		}
62
63
		$this->newQuery()->eagerLoad()->setClauses()->setScopes();
64
65
		$this->with('properties')->whereHas('properties', function($query) use ($property, $property_value) {
66
			$query->where('value', $property_value);
67
			$query->where('key', $property);
68
		});
69
70
		return $this->paginate($limit, ['*'], $pageName, $page);
71
72
	}
73
74
//DatastoreDatastoreRepository
75
76
}
77