Created
January 22, 2015 17:14
-
-
Save eimihar/c4266dcb54a30af9a272 to your computer and use it in GitHub Desktop.
Some pseudo codes of simple mvc logic handling
This file contains 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 | |
// Within controller | |
// example laravel eloquent ORM syntax | |
$user = user::find(1); // return \Model\User | |
$locations = location::findAll(); // return \Collection | |
$categories = category::findAll(); // return \Collection | |
$myform = new Form; | |
// populate with value | |
$myform->setData(array( | |
'username'=> $user->username, | |
'name'=> $user->name | |
)); | |
// populate input option with categories and locations | |
$myform->setOption('category', $categories->toArray()); | |
$myform->setOption('location', $locations->toArray()); | |
// Within view | |
echo $myform->text('username'); | |
echo $myform->text('name'); | |
echo $myform->select('location'); | |
echo $myform->select('category'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment