Created
October 2, 2015 03:24
-
-
Save alfchee/6e1dd7df014d9fc2fea2 to your computer and use it in GitHub Desktop.
It's an abstract class that works magic methods and properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class AbstractModel { | |
| protected $fillable = array(); | |
| protected $data = array(); | |
| // set magicaly the data attributes | |
| protected function __set($name,$value) { | |
| $this->data[$name] = $value; | |
| }//__set() | |
| protected function __get($name) { | |
| if(array_key_exists($name, $this->data)) { | |
| return $this->data[$name]; | |
| } | |
| return null; | |
| }//__get() | |
| protected function __isset($name) { | |
| return isset($this->data['name']); | |
| } | |
| protected function __unset($name) { | |
| unset($this->data[$name]); | |
| }//__unset() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment