Casts
1 month ago
Concerns
1 month ago
Factories
1 month ago
Relations
1 month ago
BroadcastableModelEventOccurred.php
1 month ago
BroadcastsEvents.php
6 months ago
Builder.php
1 month ago
Collection.php
1 month ago
HigherOrderBuilderProxy.php
2 years ago
InvalidCastException.php
2 years ago
JsonEncodingException.php
2 years ago
MassAssignmentException.php
2 years ago
MassPrunable.php
6 months ago
MissingAttributeException.php
1 month ago
Model.php
1 month ago
ModelNotFoundException.php
1 month ago
PendingHasThroughRelationship.php
1 month ago
Prunable.php
2 years ago
QueueEntityResolver.php
2 years ago
RelationNotFoundException.php
2 years ago
Scope.php
2 years ago
SoftDeletes.php
1 month ago
SoftDeletingScope.php
1 month ago
JsonEncodingException.php
46 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWPSCOPED\Illuminate\Database\Eloquent; |
| 4 | |
| 5 | use RuntimeException; |
| 6 | /** @internal */ |
| 7 | class JsonEncodingException extends RuntimeException |
| 8 | { |
| 9 | /** |
| 10 | * Create a new JSON encoding exception for the model. |
| 11 | * |
| 12 | * @param mixed $model |
| 13 | * @param string $message |
| 14 | * @return static |
| 15 | */ |
| 16 | public static function forModel($model, $message) |
| 17 | { |
| 18 | return new static('Error encoding model [' . \get_class($model) . '] with ID [' . $model->getKey() . '] to JSON: ' . $message); |
| 19 | } |
| 20 | /** |
| 21 | * Create a new JSON encoding exception for the resource. |
| 22 | * |
| 23 | * @param \Illuminate\Http\Resources\Json\JsonResource $resource |
| 24 | * @param string $message |
| 25 | * @return static |
| 26 | */ |
| 27 | public static function forResource($resource, $message) |
| 28 | { |
| 29 | $model = $resource->resource; |
| 30 | return new static('Error encoding resource [' . \get_class($resource) . '] with model [' . \get_class($model) . '] with ID [' . $model->getKey() . '] to JSON: ' . $message); |
| 31 | } |
| 32 | /** |
| 33 | * Create a new JSON encoding exception for an attribute. |
| 34 | * |
| 35 | * @param mixed $model |
| 36 | * @param mixed $key |
| 37 | * @param string $message |
| 38 | * @return static |
| 39 | */ |
| 40 | public static function forAttribute($model, $key, $message) |
| 41 | { |
| 42 | $class = \get_class($model); |
| 43 | return new static("Unable to encode attribute [{$key}] for model [{$class}] to JSON: {$message}."); |
| 44 | } |
| 45 | } |
| 46 |