Last active
December 16, 2015 12:59
-
-
Save jamsesso/5438548 to your computer and use it in GitHub Desktop.
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 | |
namespace Scarf\Views; | |
use Scarf\Models\Contacts; | |
use Scarf\Library\Layout\Templates; | |
/* Creates a URL at http://.../contacts */ | |
class Contacts | |
{ | |
/* The main page when /contacts is visited. */ | |
public function main() | |
{ | |
Templates::get("list_contacts", array( | |
"contacts" => Contacts::all() | |
)); | |
} | |
/* Defines a page to add a contact: /contacts/add */ | |
public function add() | |
{ | |
Templates::get("add_contact"); | |
} | |
/* Back end page to create a contact. Protected | |
functions are accessible during post requests. */ | |
protected function create(Post $name, Post $phone) | |
{ | |
Contacts::create([ | |
"name" => $name, | |
"phone" => $phone | |
]); | |
redirect("Contacts"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment