Skip to content

Instantly share code, notes, and snippets.

@kticka
Last active March 23, 2017 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kticka/1b960d2175d89de0cb36568f67aa4a73 to your computer and use it in GitHub Desktop.
Save kticka/1b960d2175d89de0cb36568f67aa4a73 to your computer and use it in GitHub Desktop.
trait Serializable
{
protected static $vColumns = [];
public static function setVisibleColumns($columns = []) {
static::$vColumns = $columns;
}
public function toJson($options = 0) {
$this->setVisible(static::$vColumns);
return parent::toJson($options);
}
public function toArray() {
$this->setVisible(static::$vColumns);
return parent::toArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment