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