Vocabulary::termsByMany()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Fomvasss\Taxonomy\Models;
4
5
use Fomvasss\Taxonomy\Models\Traits\HasTaxonomyablesToMany;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\SoftDeletes;
8
9
class Vocabulary extends Model
10
{
11
    use HasTaxonomyablesToMany;
12
13
    protected $guarded = ['id'];
14
15
    public $timestamps = false;
16
17
    protected $casts = [
18
        'options' => 'array',
19
    ];
20
21
    /**
22
     * Связь:
23
     * Словарь имеет много термов
24
     *
25
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
26
     */
27
    public function terms()
28
    {
29
        $related = config('taxonomy.models.term', Term::class);
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        $related = /** @scrutinizer ignore-call */ config('taxonomy.models.term', Term::class);
Loading history...
30
        
31
        return $this->hasMany($related, 'vocabulary');
32
    }
33
34
    /**
35
     * Связь:
36
     * Сущность текущей модели - словарь "держит" много термов
37
     * (полиморфная связь! - не используется в этом пакете для категоризации)
38
     *
39
     * @return $this
40
     */
41
    public function termsByMany()
42
    {
43
        $related = config('taxonomy.models.term', Term::class);
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $related = /** @scrutinizer ignore-call */ config('taxonomy.models.term', Term::class);
Loading history...
44
        
45
        return $this->morphedByMany($related, 'vocabularyable');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->morphedByM...ated, 'vocabularyable') returns the type Illuminate\Database\Eloquent\Relations\MorphToMany which is incompatible with the documented return type Fomvasss\Taxonomy\Models\Vocabulary.
Loading history...
46
    }
47
48
    /**
49
     * Связь:
50
     * Сущность текущей модели - словарь "держит" много словарей
51
     * (полиморфная связь! - не используется в этом пакете для категоризации)
52
     *
53
     * @return $this
54
     */
55
    public function vocabulariesByMany()
56
    {
57
        $related = config('taxonomy.models.vocabulary', static::class);
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
        $related = /** @scrutinizer ignore-call */ config('taxonomy.models.vocabulary', static::class);
Loading history...
58
        
59
        return $this->morphedByMany($related, 'vocabularyable');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->morphedByM...ated, 'vocabularyable') returns the type Illuminate\Database\Eloquent\Relations\MorphToMany which is incompatible with the documented return type Fomvasss\Taxonomy\Models\Vocabulary.
Loading history...
60
    }
61
}
62