UpdatePictureRequest::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace FaithGen\Sermons\Http\Requests;
4
5
use FaithGen\Sermons\SermonService;
6
use Illuminate\Auth\Access\AuthorizationException;
7
use Illuminate\Foundation\Http\FormRequest;
8
9
class UpdatePictureRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @param \FaithGen\Sermons\SermonService $sermonService
15
     *
16
     * @return bool
17
     */
18
    public function authorize(SermonService $sermonService)
19
    {
20
        return $sermonService->getSermon()
21
            && $this->user()->can('update', $sermonService->getSermon());
22
    }
23
24
    /**
25
     * Get the validation rules that apply to the request.
26
     *
27
     * @return array
28
     */
29
    public function rules()
30
    {
31
        return [
32
            'image'    => 'base64image',
33
            'hasImage' => 'required|boolean',
34
        ];
35
    }
36
37
    public function failedAuthorization()
38
    {
39
        throw new AuthorizationException('You are not permitted to update this sermon.');
40
    }
41
}
42