DBM_MongoObject::readFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace CodexShaper\DBM\Models;
4
5
use CodexShaper\DBM\Traits\Relationships;
6
use Jenssegers\Mongodb\Eloquent\Model;
0 ignored issues
show
Bug introduced by
The type Jenssegers\Mongodb\Eloquent\Model 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
8
class DBM_MongoObject extends Model
9
{
10
    use Relationships;
11
12
    /*@var string*/
13
    protected $collection = 'dbm_objects';
14
    /*@var array*/
15
    protected $casts = [
16
        'details' => 'array',
17
    ];
18
19
    /**
20
     * Get object fields.
21
     *
22
     * @return \Illuminate\Support\Collection
23
     */
24
    public function fields()
25
    {
26
        return $this->hasMany(DBM_MongoField::class, 'dbm_object_id');
27
    }
28
29
    /**
30
     * Get all fields.
31
     *
32
     * @param string $order_by
33
     * @param string $direction
34
     *
35
     * @return \Illuminate\Support\Collection
36
     */
37
    public function allFields($order_by = 'order', $direction = 'ASC')
38
    {
39
        return $this->fields()->orderBy($order_by, $direction)->get();
40
    }
41
42
    /**
43
     * Get Create fields.
44
     *
45
     * @param string $order_by
46
     * @param string $direction
47
     *
48
     * @return \Illuminate\Support\Collection
49
     */
50
    public function createFields($order_by = 'order', $direction = 'ASC')
51
    {
52
        return $this->fields()->where('create', true)->orderBy($order_by, $direction)->get();
53
    }
54
55
    /**
56
     * Get Browse fields.
57
     *
58
     * @param string $order_by
59
     * @param string $direction
60
     *
61
     * @return \Illuminate\Support\Collection
62
     */
63
    public function readFields($order_by = 'order', $direction = 'ASC')
64
    {
65
        return $this->fields()->where('read', true)->orderBy($order_by, $direction)->get();
66
    }
67
68
    /**
69
     * Get Edit fields.
70
     *
71
     * @param string $order_by
72
     * @param string $direction
73
     *
74
     * @return \Illuminate\Support\Collection
75
     */
76
    public function editFields($order_by = 'order', $direction = 'ASC')
77
    {
78
        return $this->fields()->where('edit', true)->orderBy($order_by, $direction)->get();
79
    }
80
81
    /**
82
     * Get delete fields.
83
     *
84
     * @param string $order_by
85
     * @param string $direction
86
     *
87
     * @return \Illuminate\Support\Collection
88
     */
89
    public function deleteFields($order_by = 'order', $direction = 'ASC')
90
    {
91
        return $this->fields()->where('delete', true)->orderBy($order_by, $direction)->get();
92
    }
93
}
94