Completed
Push — master ( 002bc5...c06b9c )
by Julien
08:45
created

MoviesController::like()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 34
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 34
rs 8.8571
cc 2
eloc 11
nc 2
nop 2
1
<?php
2
// chemin relatif ou se trouve la classe
3
namespace App\Http\Controllers;
4
5
6
use App\Http\Models\Actors;
7
use App\Http\Models\Categories;
8
use App\Http\Models\Directors;
9
use App\Http\Models\Movies;
10
use App\Http\Requests\MoviesRequest;
11
use Illuminate\Http\Request;
12
use Illuminate\Support\Facades\DB;
13
use Illuminate\Support\Facades\Redirect;
14
use Illuminate\Support\Facades\Session;
15
16
17
/**
18
 * Class MainController
19
 * @package App\Http\Controllers
20
 * Sufficé par le mot clef Controller
21
 * et doit hérité de la super classe Controller
22
 */
23
class MoviesController extends Controller{
24
25
26
    /**
27
     * Page Acceuil
28
     */
29
    public function index(){
30
31
        $movies = Movies::all();
32
33
        return view('Movies/index',[
34
                'movies' => $movies
35
            ]
36
        );
37
    }
38
39
    /**
40
     * Page Create
41
     */
42
    public function create(){
43
44
        $categories = Categories::all();
45
        $actors = Actors::all();
46
        $directors = Directors::all();
47
48
        return view('Movies/create',
49
        [
50
            'categories' => $categories,
51
            'actors' => $actors,
52
            'directors' => $directors,
53
        ]);
54
55
    }
56
57
58
    /**
59
     * Page Read
60
     */
61
    public function read($id){
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
63
        return view('Movies/read');
64
    }
65
    /**
66
     * Page Read
67
     */
68
    public function edit($id){
69
70
        $categories = Categories::all();
71
        $actors = Actors::all();
72
        $directors = Directors::all();
73
74
        $movie = Movies::find($id);
75
        return view('Movies/edit', [
76
            'movie' => $movie,
77
            'categories' => $categories,
78
            'actors' => $actors,
79
            'directors' => $directors,
80
        ]);
81
    }
82
83
84
    /**
85
     * Action qui va me permettre d'activer un film
86
     * @param $id
87
     */
88 View Code Duplication
    public function activate($id){
0 ignored issues
show
Duplication introduced by
This method 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...
89
        $movie = Movies::find($id);
90
91
        if($movie->visible == 0){
92
            $movie->visible = 1;
93
            Session::flash("success","Le film {$movie->title} a bien été activé");
94
95
        }
96
        else{
97
            $movie->visible = 0;
98
            Session::flash("success","Le film {$movie->title} a bien été desactivé");
99
        }
100
101
        $movie->save();
102
103
        return Redirect::route('movies_index');
104
    }
105
106
107
    /**
108
     * Action qui va me permettre de metter en avant un film
109
     * @param $id
110
     */
111 View Code Duplication
    public function cover($id){
0 ignored issues
show
Duplication introduced by
This method 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...
112
        // find() permet de retourner un Objet Movie
113
        // depuis son id
114
        $movie = Movies::find($id);
115
116
        if($movie->cover == 0){
117
            $movie->cover = 1;
118
            Session::flash("success","Le film {$movie->title} a bien été mis en avant");
119
120
        }
121
        else{
122
            $movie->cover = 0;
123
            Session::flash("danger","Le film {$movie->title} a bien été retiré de l'avant");
124
        }
125
126
        $movie->save();
127
128
        return Redirect::route('movies_index');
129
    }
130
131
132
133
    /**
134
     * Suppresion
135
     */
136
    public function delete($id){
137
138
        $movie = Movies::find($id);
139
140
        if($movie){
141
            Session::flash('success', "Le film {$movie->title} a bien été supprimé");
142
            $movie->delete();
143
        }
144
145
        return Redirect::route('movies_index');
146
    }
147
148
149
    /**
150
     * Fonction de like des films, enregistré en session
151
     * Session : mécanisme de stockage temporelle
152
     * BDD: mécanisme de stockage atemporelle
153
     * @param Request $request
0 ignored issues
show
Bug introduced by
There is no parameter named $request. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
154
     */
155
    public function like($id, $action)
156
    {
157
        // je recupère le film (objet MOvies)
158
        $movie = Movies::find($id);
159
160
        // je recupère ma variable likes en session
161
        // et je fixe un tableau par défaut
162
        // si j'ai rien en sessions likes
163
        $likes = session("likes", []);
164
165
        // si l'action est "like"
166
        if ($action == "like") {
167
168
            // J'ajoute mon movie dans le tableaux des likes en session
169
            $likes[$id] = $movie->id;
170
            Session::flash('danger', "Le film {$movie->title} a bien été liké");
171
172
        }else{
173
174
            // je supprime le like dans le tableaux des likes
175
            // unset() supprimer un element dans un tableau en PHP
176
            unset($likes[$id]);
177
178
            Session::flash('success', "Le film {$movie->title} a bien été disliké");
179
        }
180
181
182
        //j'enregistre en session mon nouveau tableaux des likes
183
        Session::put("likes", $likes);
184
185
        // une redirection avec message flash
186
        return Redirect::route('movies_index');
187
188
    }
189
190
191
192
    /**
193
     * Store database
194
     */
195
    public function store(MoviesRequest $request){
196
197
        $dateoutput =  \DateTime::createFromFormat('d/m/Y',$request->date_release);
0 ignored issues
show
Documentation introduced by
The property date_release does not exist on object<App\Http\Requests\MoviesRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
198
        $movie = new Movies();
199
        $movie->type = $request->type;
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property type does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
200
        $movie->title = $request->title;
0 ignored issues
show
Documentation introduced by
The property title does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property title does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
201
        $movie->synopsis = $request->synopsis;
0 ignored issues
show
Documentation introduced by
The property synopsis does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property synopsis does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
202
        $movie->description = $request->description;
0 ignored issues
show
Documentation introduced by
The property description does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property description does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
203
        $movie->trailer = $request->trailer;
0 ignored issues
show
Documentation introduced by
The property trailer does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property trailer does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
204
        $movie->date_release = $dateoutput;
0 ignored issues
show
Documentation introduced by
The property date_release does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
205
        $movie->visible = $request->visible;
0 ignored issues
show
Documentation introduced by
The property $visible is declared protected in Illuminate\Database\Eloquent\Model. Since you implemented __set(), maybe consider adding a @property or @property-write annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property visible does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
206
        $movie->cover = $request->cover;
0 ignored issues
show
Documentation introduced by
The property cover does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property cover does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
207
        $movie->languages = $request->lang;
0 ignored issues
show
Documentation introduced by
The property languages does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property lang does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
208
        $movie->categories_id = $request->categories_id;
0 ignored issues
show
Documentation introduced by
The property categories_id does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property categories_id does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
209
        $movie->note_presse = $request->note_presse;
0 ignored issues
show
Documentation introduced by
The property note_presse does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property note_presse does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
210
        $movie->distributeur = $request->distributeur;
0 ignored issues
show
Documentation introduced by
The property distributeur does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The property distributeur does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
211
212
        $filename = "";
213
214
        if($request->hasFile('image')) {
215
            $file = $request->file('image');
216
            $filename = $file->getClientOriginalName(); // Récupère le nom original du fichier
217
            $destinationPath = public_path() . '/uploads/movies'; // Indique où stocker le fichier
218
            $file->move($destinationPath, $filename); // Déplace le fichier
219
        }
220
221
        $movie->image = asset("uploads/movies/". $filename);
0 ignored issues
show
Documentation introduced by
The property image does not exist on object<App\Http\Models\Movies>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
222
        $movie->save();
223
224
        $actors = $request->actors;
0 ignored issues
show
Bug introduced by
The property actors does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
225
        if (isset($actors)) {
226
            foreach ($actors as $actor) {
227
                DB::table('actors_movies')
228
                    ->insert([
229
                        ['movies_id' => $movie->id, 'actors_id' => $actor]
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Http\Models\Movies>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
230
                    ]);
231
            }
232
        }
233
234
        $directors = $request->directors;
0 ignored issues
show
Bug introduced by
The property directors does not seem to exist in App\Http\Requests\MoviesRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
235
        if (isset($directors)) {
236
            foreach ($directors as $director) {
237
                DB::table('directors_movies')
238
                    ->insert([
239
                        ['movies_id' => $movie->id, 'directors_id' => $director]
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Http\Models\Movies>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
240
                    ]);
241
            }
242
        }
243
244
245
        Session::flash('success', "Le film {$movie->title} a été enregistré");
0 ignored issues
show
Documentation introduced by
The property title does not exist on object<App\Http\Models\Movies>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
246
        return Redirect::route('movies_index');
247
248
    }
249
250
251
}
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270