-
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
discardedAttributeViolationReporter
- Loading branch information
1 parent
ba4fdac
commit 70d2134
Showing
2 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Sentry/Laravel/Integration/ModelViolations/DiscardedAttributeViolationReporter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Sentry\Laravel\Integration\ModelViolations; | ||
|
||
use Exception; | ||
use Illuminate\Database\Eloquent\MassAssignmentException; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class DiscardedAttributeViolationReporter extends ModelViolationReporter | ||
{ | ||
protected function getViolationContext(Model $model, string $property): array | ||
{ | ||
return [ | ||
'attribute' => $property, | ||
'kind' => 'discarded_attribute', | ||
]; | ||
} | ||
|
||
protected function getViolationException(Model $model, string $property): Exception | ||
{ | ||
return new MassAssignmentException(sprintf( | ||
'Add [%s] to fillable property to allow mass assignment on [%s].', | ||
$property, | ||
get_class($model) | ||
)); | ||
} | ||
} |