Skip to content

Instantly share code, notes, and snippets.

@eimihar
Created January 22, 2015 17:14
Show Gist options
  • Save eimihar/c4266dcb54a30af9a272 to your computer and use it in GitHub Desktop.
Save eimihar/c4266dcb54a30af9a272 to your computer and use it in GitHub Desktop.
Some pseudo codes of simple mvc logic handling
<?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