Passed
Push — master ( 0378d7...bd60cc )
by
04:19
created

FaqArticleRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Qsnh/meedu.
5
 *
6
 * (c) XiaoTeng <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace App\Http\Requests\Backend;
13
14
use Illuminate\Foundation\Http\FormRequest;
15
16
class FaqArticleRequest extends FormRequest
17
{
18
    /**
19
     * Determine if the user is authorized to make this request.
20
     *
21
     * @return bool
22
     */
23
    public function authorize()
24
    {
25
        return true;
26
    }
27
28
    /**
29
     * Get the validation rules that apply to the request.
30
     *
31
     * @return array
32
     */
33
    public function rules()
34
    {
35
        return [
36
            'category_id' => 'required',
37
            'title' => 'required|max:255',
38
            'content' => 'required',
39
        ];
40
    }
41
42
    public function messages()
43
    {
44
        return [
45
            'category_id.required' => '请选择分类',
46
            'title.required' => '请输入标题',
47
            'title.max' => '标题不能超过255个字',
48
            'content.required' => '请输入内容',
49
        ];
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function filldata(): array
56
    {
57
        return [
58
            'admin_id' => admin()->id,
59
            'category_id' => $this->input('category_id'),
60
            'title' => $this->input('title'),
61
            'content' => $this->input('content'),
62
        ];
63
    }
64
}
65