Passed
Push — 5.0.0 ( 7b1056...f0e712 )
by Fèvre
05:33
created

CommentForm::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Livewire\Forms;
6
7
use Livewire\Attributes\Locked;
8
use Livewire\Form;
9
use Xetaravel\Models\BlogComment;
10
11
class CommentForm extends Form
12
{
13
    #[Locked]
14
    public ?int $blog_article_id = null;
15
16
    public ?string $content = null;
17
18
    /**
19
     * Rules used for validating the model.
20
     *
21
     * @return array
22
     */
23
    public function rules(): array
24
    {
25
        return [
26
            'content' => 'required|min:10'
27
        ];
28
    }
29
30
    /**
31
     * Translated attribute used in failed messages.
32
     *
33
     * @return array
34
     */
35
    public function validationAttributes(): array
36
    {
37
        return [
38
            'content' => 'commentaire'
39
        ];
40
    }
41
42
    /**
43
     * Function to store the model.
44
     *
45
     * @return BlogComment
46
     */
47
    public function store(): BlogComment
48
    {
49
        return BlogComment::create($this->only([
50
            'blog_article_id',
51
            'content'
52
        ]));
53
    }
54
}
55