Skip to content

Commit

Permalink
Add toArray() and toJSON() methods to User.
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Dec 22, 2015
1 parent efbd936 commit cbfd0d7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/AttributeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,24 @@ public function __get($property)
{
return $this->getAttribute($property);
}

/**
* Return array.
*
* @return array
*/
public function toArray()
{
return $this->getAttributes();
}

/**
* Return JSON.
*
* @return string
*/
public function toJSON()
{
return json_encode($this->getAttributes(), JSON_UNESCAPED_UNICODE);
}
}

0 comments on commit cbfd0d7

Please sign in to comment.