Completed
Push — master ( 8fcc32...ae3918 )
by Innocent
01:13
created

UpdateRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Faithgen\Discussions\Http\Requests;
4
5
use Faithgen\Discussions\Services\DiscussionService;
6
use Faithgen\Discussions\Traits\SavesDiscussion;
7
use FaithGen\SDK\Helpers\Helper;
8
use Illuminate\Foundation\Http\FormRequest;
9
10 View Code Duplication
class UpdateRequest extends FormRequest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    use SavesDiscussion;
13
14
    /**
15
     * Determine if the user is authorized to make this request.
16
     *
17
     * @param  DiscussionService  $discussionService
18
     *
19
     * @return bool
20
     */
21
    public function authorize(DiscussionService $discussionService)
22
    {
23
        if (! $discussionService->getDiscussion()) {
24
            return false;
25
        }
26
27
        return $this->user()->can('update', $discussionService->getDiscussion());
28
    }
29
30
    /**
31
     * Get the validation rules that apply to the request.
32
     *
33
     * @return array
34
     */
35
    public function rules()
36
    {
37
        return array_merge([
38
            'discussion_id' => Helper::$idValidation,
39
            'title'         => 'required|string',
40
        ], $this->getSaveRules());
41
    }
42
}
43