Code Duplication    Length = 29-31 lines in 2 locations

src/Http/Requests/DeleteImageRequest.php 1 location

@@ 9-37 (lines=29) @@
6
use Illuminate\Auth\Access\AuthorizationException;
7
use Illuminate\Foundation\Http\FormRequest;
8
9
class DeleteImageRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @param \Faithgen\Testimonies\Services\TestimoniesService $testimoniesService
15
     *
16
     * @return bool
17
     */
18
    public function authorize(TestimoniesService $testimoniesService)
19
    {
20
        return $this->user()->can('update', $testimoniesService->getTestimony());
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
    }
32
33
    public function failedAuthorization()
34
    {
35
        throw new AuthorizationException('You can not delete images from this testimony.');
36
    }
37
}
38

src/Http/Requests/ToggleApprovalRequest.php 1 location

@@ 9-39 (lines=31) @@
6
use Illuminate\Auth\Access\AuthorizationException;
7
use Illuminate\Foundation\Http\FormRequest;
8
9
class ToggleApprovalRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @param \Faithgen\Testimonies\Services\TestimoniesService $testimoniesService
15
     *
16
     * @return bool
17
     */
18
    public function authorize(TestimoniesService $testimoniesService)
19
    {
20
        return $testimoniesService->getTestimony() && $this->user()->can('update', $testimoniesService->getTestimony());
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
            'approved' => 'required|boolean',
32
        ];
33
    }
34
35
    public function failedAuthorization()
36
    {
37
        throw new AuthorizationException('You are not permitted to transact on this testimony.');
38
    }
39
}
40