dep: package update
This commit is contained in:
+25
-2
@@ -8,6 +8,7 @@ use Illuminate\Contracts\Queue\QueueableCollection;
|
||||
use Illuminate\Contracts\Queue\QueueableEntity;
|
||||
use Illuminate\Contracts\Routing\UrlRoutable;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Contracts\Support\CanBeEscapedWhenCastToString;
|
||||
use Illuminate\Contracts\Support\Jsonable;
|
||||
use Illuminate\Database\ConnectionResolverInterface as Resolver;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
@@ -22,7 +23,7 @@ use Illuminate\Support\Traits\ForwardsCalls;
|
||||
use JsonSerializable;
|
||||
use LogicException;
|
||||
|
||||
abstract class Model implements Arrayable, ArrayAccess, HasBroadcastChannel, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable
|
||||
abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToString, HasBroadcastChannel, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable
|
||||
{
|
||||
use Concerns\HasAttributes,
|
||||
Concerns\HasEvents,
|
||||
@@ -110,6 +111,13 @@ abstract class Model implements Arrayable, ArrayAccess, HasBroadcastChannel, Jso
|
||||
*/
|
||||
public $wasRecentlyCreated = false;
|
||||
|
||||
/**
|
||||
* Indicates that the object's string representation should be escaped when __toString is invoked.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $escapeWhenCastingToString = false;
|
||||
|
||||
/**
|
||||
* The connection resolver instance.
|
||||
*
|
||||
@@ -2128,7 +2136,22 @@ abstract class Model implements Arrayable, ArrayAccess, HasBroadcastChannel, Jso
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toJson();
|
||||
return $this->escapeWhenCastingToString
|
||||
? e($this->toJson())
|
||||
: $this->toJson();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the object's string representation should be escaped when __toString is invoked.
|
||||
*
|
||||
* @param bool $escape
|
||||
* @return $this
|
||||
*/
|
||||
public function escapeWhenCastingToString($escape = true)
|
||||
{
|
||||
$this->escapeWhenCastingToString = $escape;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user