Completed
Push — master ( be2db5...c83fb2 )
by
03:24
created

IncludeTopicTrait::includeTopic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 10
loc 10
rs 9.4286
c 2
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
/**
4
 * Created by PhpStorm.
5
 * User: xuan
6
 * Date: 9/25/15
7
 * Time: 8:09 AM.
8
 */
9
namespace PHPHub\Repositories\Eloquent\Traits;
10
11
use PHPHub\Transformers\IncludeManager\Includable;
12
use PHPHub\Transformers\IncludeManager\IncludeManager;
13
use PHPHub\User;
14
15 View Code Duplication
trait IncludeTopicTrait
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * 使用 user_id 字段引入关联的用户.
19
     *
20
     * @param $default_columns
21
     */
22
    public function includeTopic($default_columns)
23
    {
24
        $available_include = Includable::make('topic')
25
            ->setDefaultColumns($default_columns)
26
            ->setAllowColumns(User::$includable)
27
            ->withTrashed()
28
            ->setForeignKey('topic_id');
29
30
        app(IncludeManager::class)->add($available_include);
31
    }
32
}
33