With our new User
object in our system, we can easily plug it into our application code, and we should be up and running.
1. Open up the
index.php
file, and changestdClass
toUser()
. While we are at it, we can also remove$user->type = 'user'
because that's now handled in our class:post('/signup', function($app) { $user = new User(); $user->name = $app->form('name'); $user->email = $app->form('email'); $app->couch->post($user); }
2. Adjust the Sag
post
statement so that we can pass our class in the JSON format:post('/signup', function($app) { $user = new User(); $user->name = $app->form('name'); $user->email = $app->form('email'); $app->couch->post($user->to_json); }