Skip to content

Commit 2e1804a

Browse files
author
Pantea Marius-ciclistu
committed
1 parent f32ffb5 commit 2e1804a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

illuminate/Database/Eloquent/Builder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,7 @@ public function __get($key)
19871987
* @param string $method
19881988
* @param array $parameters
19891989
* @return mixed
1990+
* @throws \BadMethodCallException
19901991
*/
19911992
public function __call($method, $parameters)
19921993
{

illuminate/Database/Eloquent/Model.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,13 +2350,28 @@ public function __unset($key)
23502350
* @param string $method
23512351
* @param array $parameters
23522352
* @return mixed
2353+
* @throws \BadMethodCallException
23532354
*/
23542355
public function __call($method, $parameters)
23552356
{
2356-
if (in_array($method, ['increment', 'decrement', 'incrementQuietly', 'decrementQuietly'])) {
2357+
$lowerMethod = \strtolower($method);
2358+
2359+
if (\in_array($lowerMethod, ['increment', 'decrement', 'incrementquietly', 'decrementquietly'])) {
23572360
return $this->$method(...$parameters);
23582361
}
23592362

2363+
if (\in_array($lowerMethod, ['incrementeach', 'decrementeach'])) {
2364+
/** \MacropaySolutions\MaravelRestWizard\Models\BaseModel::incrementBulk can be used instead */
2365+
throw new \BadMethodCallException(\sprintf(
2366+
'Call to unscoped method %s::%s(). Use $model->newQuery()->getQuery()->%s()' .
2367+
' for unscoped or $model->newQuery()->%s() for scoped behaviour.',
2368+
static::class,
2369+
$method,
2370+
$method,
2371+
$method,
2372+
));
2373+
}
2374+
23602375
if ($resolver = $this->relationResolver(static::class, $method)) {
23612376
return $resolver($this);
23622377
}

0 commit comments

Comments
 (0)