Issues (413)

app/Http/Requests/AdminUserUpdateRequest.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Yeelight\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Validation\Rule;
7
8
/**
9
 * Class AdminUserUpdateRequest
10
 *
11
 * @category Yeelight
12
 *
13
 * @package Yeelight\Http\Requests
14
 *
15
 * @author Sheldon Lee <[email protected]>
16
 *
17
 * @license https://opensource.org/licenses/MIT MIT
18
 *
19
 * @link https://www.yeelight.com
20
 */
21
class AdminUserUpdateRequest extends FormRequest
22
{
23
    /**
24
     * Get the URL to redirect to on a validation error.
25
     *
26
     * @return string
27
     */
28
    protected function getRedirectUrl()
29
    {
30
        return $this->getSession()->previousUrl();
0 ignored issues
show
The method previousUrl() does not exist on Symfony\Component\HttpFo...ession\SessionInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        return $this->getSession()->/** @scrutinizer ignore-call */ previousUrl();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
    }
32
33
    /**
34
     * Determine if the user is authorized to make this request.
35
     *
36
     * @return bool
37
     */
38
    public function authorize()
39
    {
40
        return true;
41
    }
42
43
    /**
44
     * Get the validation rules that apply to the request.
45
     *
46
     * @return array
47
     */
48
    public function rules()
49
    {
50
        return [
51
            'username' => [
52
                'required',
53
                Rule::unique('admin_users')->ignore($this->username, 'username'),
54
                'max:190',
55
            ],
56
            'name'                  => 'required|max:255',
57
            'password'              => 'required|confirmed',
58
            'password_confirmation' => 'required',
59
            'permissions'           => 'array',
60
            'roles'                 => 'array',
61
        ];
62
    }
63
}
64