Completed
Push — master ( f00659...1f4cdd )
by Julien
05:36
created

User   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
c 1
b 0
f 1
lcom 1
cbo 1
dl 85
loc 85
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getLastUsers() 13 13 1
A getAllMovies() 5 5 1
A categories() 4 4 1
A comments() 4 4 1
A actors() 4 4 1
A directors() 4 4 1
A sessions() 4 4 1
A recommandations() 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
namespace App\Http\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\DB;
7
8
9
/**
10
 * Classe qui va stocker mes requetes autoirs
11
 * de ma table movies
12
 * Hérite de ma super classe Model
13
 */
14 View Code Duplication
class User 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...
15
16
17
    /**
18
     * Décrit le nom de la table
19
     * que classe fait référence
20
     */
21
    protected $table = 'user';
22
23
    /**
24
     *  Retourne les 24 derniers utilisateurs
25
     */
26
    public function getLastUsers(){
27
28
        // retourne le resultat de ma requete SELECT * FROM movies
29
        $result =  DB::table('user')
30
            ->orderBy('created_at', 'DESC')
31
            ->take(24)
32
            ->get();
33
34
            //->toSql();
35
            // traduire en SQL ma requête
36
37
        return $result;
38
    }
39
40
41
    /**
42
     *  Retourne tous les films
43
     */
44
    public function getAllMovies(){
45
46
        // retourne le resultat de ma requete SELECT * FROM movies
47
        return DB::table('user')->get();
48
    }
49
50
51
52
53
54
55
56
57
58
    /**
59
     * Retourne la catégorie à laquelle appartient un objet film
60
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
61
     */
62
    public function categories()
63
    {
64
        return $this->belongsTo('App\Http\Models\Categories');
65
    }
66
67
68
    public function comments()
69
    {
70
        return $this->hasMany('App\Http\Models\Comments');
71
    }
72
73
    public function actors()
74
    {
75
        return $this->belongsToMany('App\Http\Models\Actors');
76
    }
77
78
    public function directors()
79
    {
80
        return $this->belongsToMany('App\Http\Models\Directors');
81
    }
82
83
    public function sessions()
84
    {
85
        return $this->hasMany('App\Http\Models\Sessions');
86
    }
87
88
    public function recommandations()
89
    {
90
        return $this->hasMany('App\Http\Models\Recommandations');
91
    }
92
93
94
95
96
97
98
}
99
100
101
102