Skip to content

Commit c986e12

Browse files
committed
formatting
1 parent fd3ab0c commit c986e12

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public function getRelationValue($key)
439439
}
440440

441441
if ($this->preventsLazyLoading) {
442-
$this->violatedLazyLoading($key);
442+
$this->handleLazyLoadingViolation($key);
443443
}
444444

445445
// If the "attribute" exists as a method on the model, we will just assume
@@ -461,17 +461,15 @@ public function isRelation($key)
461461
}
462462

463463
/**
464-
* Handle a lazy loading violation, for example by throwing an exception.
464+
* Handle a lazy loading violation.
465465
*
466466
* @param string $key
467-
* @return void
467+
* @return mixed
468468
*/
469-
protected function violatedLazyLoading($key)
469+
protected function handleLazyLoadingViolation($key)
470470
{
471-
if (isset(static::$violatedLazyLoadingCallback)) {
472-
call_user_func(static::$violatedLazyLoadingCallback, $this, $key);
473-
474-
return;
471+
if (isset(static::$lazyLoadingViolationCallback)) {
472+
return call_user_func(static::$lazyLoadingViolationCallback, $this, $key);
475473
}
476474

477475
throw new LazyLoadingViolationException($this, $key);

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ abstract class Model implements Arrayable, ArrayAccess, Jsonable, JsonSerializab
159159
protected static $modelsShouldPreventLazyLoading = false;
160160

161161
/**
162-
* The callback that is responsible for handing lazy loading violations.
162+
* The callback that is responsible for handling lazy loading violations.
163163
*
164164
* @var callable|null
165165
*/
166-
protected static $violatedLazyLoadingCallback;
166+
protected static $lazyLoadingViolationCallback;
167167

168168
/**
169169
* The name of the "created at" column.
@@ -368,11 +368,12 @@ public static function preventLazyLoading($value = true)
368368
/**
369369
* Register a callback that is responsible for handling lazy loading violations.
370370
*
371-
* @param callable $callback
371+
* @param callable $callback
372+
* @return void
372373
*/
373374
public static function handleLazyLoadingViolationUsing(callable $callback)
374375
{
375-
static::$violatedLazyLoadingCallback = $callback;
376+
static::$lazyLoadingViolationCallback = $callback;
376377
}
377378

378379
/**

tests/Integration/Database/EloquentStrictLoadingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function modelTwos()
154154
return $this->hasMany(EloquentStrictLoadingTestModel2::class, 'model_1_id');
155155
}
156156

157-
protected function violatedLazyLoading($key)
157+
protected function handleLazyLoadingViolation($key)
158158
{
159159
throw new \RuntimeException("Violated {$key}");
160160
}

0 commit comments

Comments
 (0)