Issues (48)

src/Http/Requests/AnnouncementRequest.php (1 issue)

Labels
Severity
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
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