CreateRequest::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
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