Completed
Push — develop ( 1eb861...f7494f )
by Neil
10s
created

DeleteUserRequest::authorize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
/**
3
 * DeleteUserRequest.php
4
 *
5
 * Validate user delete requests
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Tony Murray
23
 * @author     Tony Murray <[email protected]>
24
 */
25
26
namespace App\Http\Requests;
27
28
use Auth;
29
30
class DeleteUserRequest extends Request
31
{
32
    /**
33
     * Determine if the user is authorized to make this request.
34
     *
35
     * @return bool
36
     */
37
    public function authorize()
38
    {
39
        if (Auth::user()->isAdmin()) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return (bool) \Auth::user()->isAdmin();.
Loading history...
40
            return true;
41
        }
42
        return false;
43
    }
44
45
    /**
46
     * Get the validation rules that apply to the request.
47
     *
48
     * @return array
49
     */
50
    public function rules()
51
    {
52
        return [
53
            'user_id' => 'exists:users,user_id'
54
        ];
55
    }
56
}