Eden generic model component
composer install eden/model
Manipulating array data in most cases can be expressed as a model. Models in Eden is defined loosely and as a utility class to help managing data in a controlled and chainable format. The basic setup of a model is described in
Figure 1. Setup
$user = array( 'user_name' => 'Chris', 'user_email' => 'firstname.lastname@example.org', 'user_location' => 'Manila, Philippines'); eden('model', $user);
From here we can access properties in our model as a method, property or back as an array.
Figure 2 shows the ways to access data in action.
Figure 2. Accessing Model Properties
//set user name $model->setUserName('Chris'); // returns user email $model->getUserEmail(); // set any abstract key $model->setAnyThing('somthing'); // get any abstract key $model->getAnyThing(); //access as array echo $model['user_name']; //set as array $model['user_email'] = 'email@example.com'; //access as object echo $model->user_name; //set as object $model->user_name = 'firstname.lastname@example.org';
We added several common methods to futher manipulate model data.
Figure 3. Utility Methods
//for each row, copy the value of post_user to the user_id column $model->copy('post_user', 'user_id'); //returns a raw array (no object) $model->get();
Contributions to Eden are following the Github work flow. Please read up before contributing.
- Fork the repository
- Fire up your local terminal create a new branch from the
v4branch of your fork with a branch name describing what your changes are. Possible branch name types:
- Make your changes. Always make sure to sign-off (-s) on all commits made (git commit -s -m "Commit message")
- Please ensure to run
phpunitbefore making a pull request.
- Push your code to your remote forked version.
- Go back to your forked version on GitHub and submit a pull request.
- An Eden developer will review your code and merge it in when it has been classified as suitable.