I thought it might be helpful to show some code in context. Here's a simplified example of what I am doing:
/**
* On POST, create a new account.
*
* @param Request $request
* @return Response
* @see http://docs.com/account#post
*/
public function store(Request $request)
{
$validator = Validator::make($request->input('data'), [
'subdomain' => 'required|unique:accounts|max:50',
'name' => 'required'
]);
if($validator->fails()) {
return \Response::json(['errors' => $validator->errors()])->setStatusCode(422);
}
$account = new Account();
$account->name = $request->input('data')['name'];
$account->subdomain = $request->input('data')['subdomain'];
$account->save();
return \Response::json(['data' => array('id' => $account->id)])->setStatusCode(201);
}