AnnouncementRequest::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Adminetic\Announcement\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Support\Facades\Auth;
7
8
class AnnouncementRequest extends FormRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        return true;
18
    }
19
20
    /**
21
     * Prepare the data for validation.
22
     *
23
     * @return void
24
     */
25
    protected function prepareForValidation()
26
    {
27
        $this->merge([
28
            'user_id' => Auth::user()->id,
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
29
        ]);
30
    }
31
32
    /**
33
     * Get the validation rules that apply to the request.
34
     *
35
     * @return array
36
     */
37
    public function rules()
38
    {
39
        return [
40
            'user_id' => 'required|numeric',
41
            'medium' => 'sometimes',
42
            'audience' => 'required',
43
            'slack_notify' => 'sometimes|boolean',
44
            'body' => 'required|max:6000',
45
        ];
46
    }
47
}
48