Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
It's an abstract class that works magic methods and properties
class AbstractModel {
protected $fillable = array();
protected $data = array();
// set magicaly the data attributes
protected function __set($name,$value) {
$this->data[$name] = $value;
protected function __get($name) {
if(array_key_exists($name, $this->data)) {
return $this->data[$name];
return null;
protected function __isset($name) {
return isset($this->data['name']);
protected function __unset($name) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment