Completed
Push — master ( d1ecb8...6399e4 )
by Julien
03:46 queued 23s
created

Movies::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
rs 10
cc 1
eloc 2
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
    //protected $fillable = ['title', 'description', 'categories_id'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
19
20
21
    /**
22
     * Décrit le nom de la table
23
     * que classe fait référence
24
     */
25
    protected $table = 'movies';
26
27
28
29
    /**
30
     *  Retourne tous les films
31
     */
32
    public function getAllMovies(){
33
34
        // retourne le resultat de ma requete SELECT * FROM movies
35
        return DB::table('movies')->get();
36
37
    }
38
39
40
    /**
41
     * Return moyenne des notes de presse
42
     */
43
    public function getAvgNotePresse(){
44
        $result = DB::table('movies')
45
                ->select(DB::raw("ROUND(AVG(note_presse)) as avgpress"))
46
                ->first();
47
48
        return $result;
49
50
    }
51
52
    /***************************************************** Relationships ***********************************************************/
53
54
55
    /**
56
     * Retourne la catégorie à laquelle appartient un objet film
57
     * Many To One : n..1
58
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
59
     */
60
    public function categories()
61
    {
62
        return $this->belongsTo('App\Http\Models\Categories');
63
    }
64
65
    /**
66
     * belongsToMany(): Many To Many
67
     */
68
    public function user()
69
    {
70
        return $this->belongsToMany('App\Http\Models\User', 'user_favoris',  'movies_id', 'user_id');
71
    }
72
73
    /**
74
     * belongsToMany(): Many To Many
75
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
76
     */
77
    public function actors()
78
    {
79
        return $this->belongsToMany('App\Http\Models\Actors');
80
    }
81
82
    public function directors()
83
    {
84
        return $this->belongsToMany('App\Http\Models\Directors');
85
    }
86
87
    public function comments()
88
    {
89
        return $this->hasMany('App\Http\Models\Comments');
90
    }
91
92
    public function sessions()
93
    {
94
        return $this->hasMany('App\Http\Models\Sessions');
95
    }
96
97
    public function recommandations()
98
    {
99
        return $this->hasMany('App\Http\Models\Recommandations');
100
    }
101
102
103
104
105
106
107
}
108
109
110
111