Completed
Push — develop ( b53258...702238 )
by Tony
15:27
created

DeviceGroupRequest::rules()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 0
1
<?php
2
/**
3
 * DeviceGroupRequest.php
4
 *
5
 * Checks incoming DeviceGroup create/edits
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
class DeviceGroupRequest extends AdminOnlyRequest
29
{
30
    /**
31
     * Get the validation rules that apply to the request.
32
     *
33
     * @return array
34
     */
35
    public function rules()
36
    {
37
        $name = 'required|max:255';
38
        if ($this->isMethod('post')) {
39
            // if creating new, make sure the name is unique
40
            $name .= '|unique:device_groups';
41
        }
42
43
        return [
44
            'name'    => $name,
45
            'desc'    => 'max:255',
46
            'pattern' => 'required',
47
            'params'  => 'required|json',
48
        ];
49
    }
50
}
51