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

Movies::getAvgNotePresse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 8
loc 8
rs 9.4286
cc 1
eloc 5
nc 1
nop 0
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 Movies 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 = 'movies';
22
23
24
25
    /**
26
     *  Retourne tous les films
27
     */
28
    public function getAllMovies(){
29
30
        // retourne le resultat de ma requete SELECT * FROM movies
31
        return DB::table('movies')->get();
32
33
    }
34
35
36
    /**
37
     * Return moyenne des notes de presse
38
     */
39
    public function getAvgNotePresse(){
40
        $result = DB::table('movies')
41
                ->select(DB::raw("ROUND(AVG(note_presse)) as avgpress"))
42
                ->first();
43
44
        return $result;
45
46
    }
47
48
    /***************************************************** Relationships ***********************************************************/
49
50
51
    /**
52
     * Retourne la catégorie à laquelle appartient un objet film
53
     * Many To One : n..1
54
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
55
     */
56
    public function categories()
57
    {
58
        return $this->belongsTo('App\Http\Models\Categories');
59
    }
60
61
    /**
62
     * belongsToMany(): Many To Many
63
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
64
     */
65
    public function actors()
66
    {
67
        return $this->belongsToMany('App\Http\Models\Actors');
68
    }
69
70
    public function directors()
71
    {
72
        return $this->belongsToMany('App\Http\Models\Directors');
73
    }
74
75
    public function comments()
76
    {
77
        return $this->hasMany('App\Http\Models\Comments');
78
    }
79
80
    public function sessions()
81
    {
82
        return $this->hasMany('App\Http\Models\Sessions');
83
    }
84
85
    public function recommandations()
86
    {
87
        return $this->hasMany('App\Http\Models\Recommandations');
88
    }
89
90
91
92
93
94
95
}
96
97
98
99