Completed
Branch master (a6481d)
by Fèvre
02:12
created

CommentRepository::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
namespace Xetaravel\Models\Repositories;
3
4
use Illuminate\Support\Collection;
5
use Xetaravel\Models\Comment;
6
7
class CommentRepository
8
{
9
    /**
10
     * Create a new comment instance after a valid validation.
11
     *
12
     * @param array $data The data used to create the comment.
13
     * @param \Xetaravel\Models\User $user The current user.
14
     *
15
     * @return \Xetaravel\Models\Comment
16
     */
17
    public static function create(array $data, $user): Comment
18
    {
19
        return Comment::create([
20
            'article_id' => $data['article_id'],
21
            'user_id' => $user->id,
22
            'content' => $data['content']
23
        ]);
24
    }
25
}
26