Completed
Push — master ( a91b57...4fcfbd )
by Jan
06:59
created

Usergroup   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 69
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 69
loc 69
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A users() 4 4 1
A scopeRelationships() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Slide module model
4
 * 
5
 * Model for module Slide
6
 * 
7
 * @category Model
8
 * @subpackage Admin
9
 * @package Olapus
10
 * @author Jan Drda <[email protected]>
11
 * @copyright Jan Drda
12
 * @license https://opensource.org/licenses/MIT MIT
13
 */
14
15
namespace App;
16
17
use Illuminate\Database\Eloquent\Model;
18
use Illuminate\Database\Eloquent\SoftDeletes;
19
20 View Code Duplication
class Usergroup extends Model
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    use SoftDeletes, AdminModelTrait;
23
    
24
    /**
25
     * The database table used by the model.
26
     *
27
     * @var string
28
     */
29
    protected $table = 'usergroup';
30
    
31
    /**
32
     * The attributes that should be mutated to dates.
33
     *
34
     * @var array
35
     */
36
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
37
    
38
    /**
39
     * The attributes that are mass assignable.
40
     *
41
     * @var array
42
     */
43
    protected $fillable = ['name'];
44
45
    /**
46
     * Fields to search in fulltext mode
47
     * 
48
     * @var array
49
     */
50
    protected $fulltextFields = [
51
        'id',
52
        'name' => [
53
            'operator' => 'LIKE',
54
            'prefix' => '%',
55
            'sufix' => '%'
56
        ],
57
    ];
58
    
59
    /**
60
     * Default order by
61
     * 
62
     * @var array
63
     */
64
    protected $defaultOrderBy = [
65
      'id' => 'desc'  
66
    ];
67
    
68
    /**
69
     * Slide link
70
     * 
71
     * @return object
72
     */
73
    public function users(){
74
        
75
        return $this->hasMany('App\User', 'usergroup_id');
76
    }
77
    
78
    /**
79
     * Process relationships
80
     * 
81
     * @param query $query
82
     * @return query
83
     */
84
    public function scopeRelationships($query){
85
        
86
        return $query->with('users');
87
    }
88
}
89