Completed
Pull Request — master (#34)
by Fèvre
05:50 queued 02:49
created

DiscussUserRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 1
1
<?php
2
namespace Xetaravel\Models\Repositories;
3
4
use Illuminate\Support\Facades\Auth;
5
use Xetaravel\Models\DiscussUser;
6
7
class DiscussUserRepository
8
{
9
    /**
10
     * Create a new post instance after a valid validation.
11
     *
12
     * @param array $data The data used to create the user.
13
     *
14
     * @return \Xetaravel\Models\DiscussUser
15
     */
16
    public static function create(array $data): DiscussUser
17
    {
18
        return DiscussUser::updateOrCreate(
19
            [
20
                'user_id' => Auth::id(),
21
                'conversation_id' => $data['conversation_id']
22
            ],
23
            [
24
                'conversation_id' => $data['conversation_id']
25
            ]
26
        );
27
    }
28
}
29