| Conditions | 5 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | 6 | public function limit($value) |
|
| 28 | { |
||
| 29 | 6 | if ($this->farParent->exists) { |
|
| 30 | 5 | $this->query->limit($value); |
|
| 31 | } else { |
||
| 32 | 1 | if (!class_exists('Staudenmeir\EloquentEagerLimit\Builder')) { |
|
| 33 | $message = 'Please install staudenmeir/eloquent-eager-limit to limit eager loading queries.'; // @codeCoverageIgnore |
||
| 34 | |||
| 35 | throw new RuntimeException($message); // @codeCoverageIgnore |
||
| 36 | } |
||
| 37 | |||
| 38 | 1 | $column = $this->getQualifiedFirstKeyName(); |
|
|
|
|||
| 39 | |||
| 40 | 1 | $grammar = $this->query->getQuery()->getGrammar(); |
|
| 41 | |||
| 42 | 1 | if ($grammar instanceof MySqlGrammar && $grammar->useLegacyGroupLimit($this->query->getQuery())) { |
|
| 43 | 1 | $column = 'laravel_through_key'; |
|
| 44 | } |
||
| 45 | |||
| 46 | 1 | $this->query->groupLimit($value, $column); |
|
| 47 | } |
||
| 48 | |||
| 49 | 6 | return $this; |
|
| 50 | } |
||
| 52 |