MoviesController::store()   B
last analyzed

Complexity

Conditions 6
Paths 8

Size

Total Lines 54
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 4
Metric Value
c 5
b 0
f 4
dl 0
loc 54
rs 8.7449
cc 6
eloc 37
nc 8
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Http\Models\Actors;
6
use App\Http\Models\Categories;
7
use App\Http\Models\Directors;
8
use App\Http\Models\Movies;
9
use App\Http\Requests\MoviesRequest;
10
use Illuminate\Http\Request;
11
use Illuminate\Support\Facades\DB;
12
use Illuminate\Support\Facades\Redirect;
13
use Illuminate\Support\Facades\Session;
14
15
/**
16
 * Class MoviesController.
17
 */
18
class MoviesController extends Controller
19
{
20
    /**
21
     * Page Index.
22
     *
23
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
24
     */
25
    public function index()
26
    {
27
        $movies = Movies::all();
28
29
        return view('Movies/index', [
30
                'movies' => $movies,
31
            ]
32
        );
33
    }
34
35
    /**
36
     * Page create.
37
     *
38
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
39
     */
40
    public function create()
41
    {
42
        $categories = Categories::all();
43
        $actors = Actors::all();
44
        $directors = Directors::all();
45
46
        return view('Movies/create',
47
        [
48
            'categories' => $categories,
49
            'actors'     => $actors,
50
            'directors'  => $directors,
51
        ]);
52
    }
53
54
    /**
55
     * Page Read.
56
     */
57
    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...
58
    {
59
        return view('Movies/read');
60
    }
61
62
    /**
63
     * Page edit.
64
     *
65
     * @param $id
66
     *
67
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
68
     */
69
    public function edit($id)
70
    {
71
        $categories = Categories::all();
72
        $actors = Actors::all();
73
        $directors = Directors::all();
74
75
        $movie = Movies::find($id);
76
77
        return view('Movies/edit', [
78
            'movie'      => $movie,
79
            'categories' => $categories,
80
            'actors'     => $actors,
81
            'directors'  => $directors,
82
        ]);
83
    }
84
85
    /**
86
     * Action qui va me permettre d'activer un film.
87
     *
88
     * @param $id
89
     */
90 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...
91
    {
92
        $movie = Movies::find($id);
93
94
        if ($movie->visible == 0) {
95
            $movie->visible = 1;
96
            Session::flash('success', "Le film {$movie->title} a bien été activé");
97
        } else {
98
            $movie->visible = 0;
99
            Session::flash('success', "Le film {$movie->title} a bien été desactivé");
100
        }
101
102
        $movie->save();
103
104
        return Redirect::route('movies_index');
105
    }
106
107
    /**
108
     * Action qui va me permettre de metter en avant un film.
109
     *
110
     * @param $id
111
     */
112 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...
113
    {
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
        } else {
120
            $movie->cover = 0;
121
            Session::flash('danger', "Le film {$movie->title} a bien été retiré de l'avant");
122
        }
123
124
        $movie->save();
125
126
        return Redirect::route('movies_index');
127
    }
128
129
    /**
130
     * Action of suppression.
131
     *
132
     * @param $id
133
     *
134
     * @return mixed
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
     * Fonction de like des films, enregistré en session
150
     * Session : mécanisme de stockage temporelle
151
     * BDD: mécanisme de stockage atemporelle.
152
     *
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
        $movie = Movies::find($id);
158
159
        $likes = session('likes', []);
160
161
        // si l'action est "like"
162
        if ($action == 'like') {
163
164
            // J'ajoute mon movie dans le tableaux des likes en session
165
            $likes[$id] = $movie->id;
166
            Session::flash('danger', "Le film {$movie->title} a bien été liké");
167
        } else {
168
169
            // je supprime le like dans le tableaux des likes
170
            // unset() supprimer un element dans un tableau en PHP
171
            unset($likes[$id]);
172
173
            Session::flash('success', "Le film {$movie->title} a bien été disliké");
174
        }
175
176
        //j'enregistre en session mon nouveau tableaux des likes
177
        Session::put('likes', $likes);
178
179
        // une redirection avec message flash
180
        return Redirect::route('movies_index');
181
    }
182
183
    /**
184
     * Storing in database.
185
     *
186
     * @param MoviesRequest $request
187
     *
188
     * @return mixed
189
     */
190
    public function store(MoviesRequest $request)
191
    {
192
        $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...
193
        $movie = new Movies();
194
        $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...
195
        $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...
196
        $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...
197
        $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...
198
        $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...
199
        $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...
200
        $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...
201
        $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...
202
        $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...
203
        $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...
204
        $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...
205
        $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...
206
207
        $filename = '';
208
209
210
        if ($request->hasFile('image')) {
211
            $file = $request->file('image');
212
            $filename = $file->getClientOriginalName(); // Récupère le nom original du fichier
213
            $destinationPath = public_path().'/uploads/movies'; // Indique où stocker le fichier
214
            $file->move($destinationPath, $filename); // Déplace le fichier
215
        }
216
217
        $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...
218
        $movie->save();
219
220
        $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...
221
        if (isset($actors)) {
222
            foreach ($actors as $actor) {
223
                DB::table('actors_movies')
224
                    ->insert([
225
                        ['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...
226
                    ]);
227
            }
228
        }
229
230
        $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...
231
        if (isset($directors)) {
232
            foreach ($directors as $director) {
233
                DB::table('directors_movies')
234
                    ->insert([
235
                        ['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...
236
                    ]);
237
            }
238
        }
239
240
        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...
241
242
        return Redirect::route('movies_index');
243
    }
244
}
245