Code Duplication    Length = 10-11 lines in 2 locations

src/Queries/Traits/HasJoinRelation.php 1 location

@@ 25-34 (lines=10) @@
22
                );
23
24
        //Has many
25
        } elseif ($field = $table2->getJoinField($table1)) {
26
            $this->query
27
                ->join(
28
                    'LEFT',
29
                    (string) $table2,
30
                    sprintf('%s = %s', $field, $table1->id)
31
                );
32
33
        //Has many to many
34
        } elseif ($joinTable = $table1->getJoinTable($table2)) {
35
            $field1 = $joinTable->getJoinField($table1);
36
            $field2 = $joinTable->getJoinField($table2);
37

src/Queries/Traits/HasRelatedWith.php 1 location

@@ 43-53 (lines=11) @@
40
        }
41
42
        //Has many
43
        if ($field = $table2->getJoinField($table1)) {
44
            $this->query
45
                ->join(
46
                    'LEFT',
47
                    (string) $table2,
48
                    sprintf('%s = %s', $field, $table1->id)
49
                )
50
                ->where(sprintf('%s IS NOT NULL', $field));
51
52
            return $this;
53
        }
54
55
        //Has many to many
56
        if ($joinTable = $table1->getJoinTable($table2)) {