Conditions | 2 |
Paths | 2 |
Total Lines | 33 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function limit($value) |
||
20 | { |
||
21 | if ($this->parent->exists) { |
||
22 | $this->query->limit($value); |
||
23 | } else { |
||
24 | $grammar = $this->getEagerLimitGrammar(); |
||
25 | |||
26 | $sql = $grammar->compileFirstPathSegment( |
||
27 | $this->related->qualifyColumn( |
||
28 | $this->related->getPathName() |
||
29 | ) |
||
30 | ); |
||
31 | |||
32 | $column = new Expression($sql); |
||
33 | |||
34 | // TODO |
||
35 | // if ($grammar instanceof MySqlGrammar && $grammar->useLegacyGroupLimit($this->query->getQuery())) { |
||
36 | // $column = 'laravel_through_key'; |
||
37 | // } |
||
38 | |||
39 | $this->query->groupLimit($value, $column); |
||
40 | |||
41 | $this->query->getQuery()->addBinding( |
||
42 | array_fill( |
||
43 | 0, |
||
44 | substr_count($sql, '?'), |
||
45 | $this->related->getPathSeparator() |
||
46 | ), |
||
47 | 'groupBy' |
||
48 | ); |
||
49 | } |
||
50 | |||
51 | return $this; |
||
52 | } |
||
54 |