Ajout jsonserializable
This commit is contained in:
@@ -5,9 +5,10 @@ namespace Kletellier\PdoWrapper;
|
||||
use ArrayIterator;
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
use JsonSerializable;
|
||||
use Traversable;
|
||||
|
||||
class Collection implements IteratorAggregate, Countable
|
||||
class Collection implements IteratorAggregate, Countable, JsonSerializable
|
||||
{
|
||||
private array $elements;
|
||||
|
||||
@@ -111,4 +112,9 @@ class Collection implements IteratorAggregate, Countable
|
||||
{
|
||||
return new ArrayIterator($this->elements);
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Kletellier\PdoWrapper;
|
||||
|
||||
class Model
|
||||
use JsonSerializable;
|
||||
|
||||
class Model implements JsonSerializable
|
||||
{
|
||||
protected mixed $values;
|
||||
protected array $updated;
|
||||
@@ -153,4 +155,9 @@ class Model
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user