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

DiscussUserRepository::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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