<?php
class UserController extends \BaseController
{
public function create()
{
return View::make('users.create');
}
public function store()
{
$rules = array(
'first' => 'required|min:3',
'last' => 'required|min:3',
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
return Redirect::to('users/create')
->withErrors($validator)
->withInput(Input::except('password'));
} else
{
$user = User::firstOrCreate(
array('first' => Input::get('first'),
'last' => Input::get('last'),
'email' => Input::get('email'),
'password' => Hash::make(\Input::get('password'))));
if($user->save())
{
$user_id = $user->id;
return Redirect::to('users/group')->with('success', 'You have successfully registered')
->with('id', $user_id);
}else
{
return \Redirect::to('users/create')->with('errors', 'Something terrible happened');
}
}
}
/**
* Display the mentor or mentee choice view
* @return Response
*/
public function chooseGroup()
{
return View::make('users.group')->with('id', array());
}
/**
* Handles POST to complete user profile
* @param int $id user id
* @return Response
*/
public function completeProfile($id)
{
$user = User::find($id);
return View::make('users.complete', array('user' => $user));
}
/**
* Handles POST request to update user profile
* @param $id of the user being updated
* @return Response
*/
public function saveProfile($id)
{
$user = User::find($id);
}
/**
* Display the view of a single user
* @param $id user id to be displayed
* @return Response
*/
public function viewProfile($id)
{
$user = User::find($id);
return View::make('users.profile', array('user' => $user));
}
/**
* Display view to edit a given user
* @param $id of the user being updated
* @return Response
*/
public function edit($id)
{
$user = User::find($id);
return View::make('users.edit', array('user' => $user));
}
/**
* Handle POST request to delete a user
* @param $id of the user to destroy
* @return Response
*/
public function destroy($id)
{
$user = User::destroy($id);
}
}