UpdateRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A failedAuthorization() 0 3 1
A rules() 0 5 1
A authorize() 0 3 1
1
<?php
2
3
namespace FaithGen\Gallery\Http\Requests;
4
5
use FaithGen\Gallery\Services\AlbumService;
6
use Illuminate\Auth\Access\AuthorizationException;
7
use Illuminate\Foundation\Http\FormRequest;
8
9
class UpdateRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @param  \FaithGen\Gallery\Services\AlbumService  $albumService
15
     *
16
     * @return bool
17
     */
18
    public function authorize(AlbumService $albumService)
19
    {
20
        return $this->user()->can('update', $albumService->getAlbum());
21
    }
22
23
    /**
24
     * Get the validation rules that apply to the request.
25
     *
26
     * @return array
27
     */
28
    public function rules()
29
    {
30
        return [
31
            'name'        => 'required|string',
32
            'description' => 'required|string',
33
        ];
34
    }
35
36
    public function failedAuthorization()
37
    {
38
        throw new AuthorizationException('You do not have access to this album');
39
    }
40
}
41