CreateRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A failedAuthorization() 0 3 1
A authorize() 0 3 1
A rules() 0 5 1
1
<?php
2
3
namespace FaithGen\Messages\Http\Requests;
4
5
use FaithGen\Messages\Models\Message;
6
use Illuminate\Auth\Access\AuthorizationException;
7
use Illuminate\Foundation\Http\FormRequest;
8
9
class CreateRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @return bool
15
     */
16
    public function authorize()
17
    {
18
        return $this->user()->can('create', Message::class);
19
    }
20
21
    /**
22
     * Get the validation rules that apply to the request.
23
     *
24
     * @return array
25
     */
26
    public function rules()
27
    {
28
        return [
29
            'title' => 'required|string',
30
            'message' => 'required|string|max:1500',
31
        ];
32
    }
33
34
    protected function failedAuthorization()
35
    {
36
        throw new AuthorizationException('You can`t create more than 10 messages when in free subscription mode, consider upgrading');
37
    }
38
}
39