mentors

mentors Git Source Tree


Root/app/controllers/UserController.php

<?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::route('group', array('user_id' => $user_id));

			}else
			{
				return \Redirect::to('create')->with('errors', 'Something terrible happened');
			}
			
		}
	}

	/**
	 * Display the two buttons for choosing between mentor and mentee
	 * @return View response
	 */
	public function chooseGroup($user_id)
	{
		return View::make('users.group')->with('user_id', $user_id);
	}

	public function completeRegistration()
	{

		$user_id = \Request::segment(3);
		$group_id =  \Request::segment(4);

		$user = User::find($user_id);

		return View::make('users.profile')->with('user', $user)->with('group_id', $group_id);

	}

}			

Archive Download this file

Branches

Number of commits:
Page rendered in 0.52278s using 11 queries.