diff --git a/app/controllers/ProjectsController.php b/app/controllers/ProjectsController.php index 481dcf5..6a76a88 100644 --- a/app/controllers/ProjectsController.php +++ b/app/controllers/ProjectsController.php @@ -9,7 +9,9 @@ class ProjectsController extends \BaseController { */ public function index() { - return View::make('projects.home'); + $projects = Project::all(); + + return View::make('projects.home')->with('projects', $projects); } @@ -32,11 +34,38 @@ class ProjectsController extends \BaseController { */ public function store() { - $data = \Input::all(); - - $project = new Project; - - $savedProject = $project->save(); + $rules = array( + 'title' => 'required|min:5', + 'link' => 'required|url', + 'language' => 'required' + ); + + $data = Input::all(); + + $validator = Validator::make($data, $rules); + + if($validator->fails()) + { + return Redirect::to('projects/create') + ->withErrors($validator) + ->withInput(Input::all()); + }else + { + $project = Project::firstOrCreate( + array( + 'title' => Input::get('title'), + 'link' => Input::get('link'), + 'language' => Input::get('language') + )); + + if($project->save()) + { + return Redirect::to('projects'); + }else{ + return Redirect::back()->with('errors', 'Something horrible happened'); + } + + } } diff --git a/app/controllers/RemindersController.php b/app/controllers/RemindersController.php index 4c502f3..da9d6b3 100644 --- a/app/controllers/RemindersController.php +++ b/app/controllers/RemindersController.php @@ -33,7 +33,12 @@ class RemindersController extends Controller { ->withInput(Input::except('password')); }else { - switch ($response = Password::remind(Input::only('email'))) + $response = Password::remind(Input::only('email'), function($message) + { + $message->subject('Mentconnect - Password Reminder!'); + }); + + switch ($response) { case Password::INVALID_USER: \Session::flash('message', 'The email you entered does not exist. Try a different email.'); diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 066d178..7387308 100644 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -45,6 +45,11 @@ class UserController extends \BaseController { $user_id = $user->id; + Mail::queue('users.welcome', array('name'=> $user->first), function($message) use ($user) + { + $message->to($user->email, $user->first . ' '. $user->last)->subject('Welcome To Mentconnect Community'); + }); + return Redirect::route('group', array('user_id' => $user_id)); }else diff --git a/app/models/Project.php b/app/models/Project.php index ff16362..3ea4de4 100644 --- a/app/models/Project.php +++ b/app/models/Project.php @@ -6,4 +6,7 @@ class Project extends Eloquent { protected $table = 'projects'; + + protected $fillable = array('title', 'link', 'language'); + } \ No newline at end of file diff --git a/app/models/User.php b/app/models/User.php index 8992b22..26e45a9 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -2,6 +2,7 @@ use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; +use Illuminate\Database\Eloquent\SoftDeletingTrait; class User extends Eloquent implements UserInterface, RemindableInterface { @@ -12,7 +13,7 @@ class User extends Eloquent implements UserInterface, RemindableInterface { * @var string */ - use SoftDeletingTrait; + protected $softDelete = true; protected $table = 'users'; diff --git a/app/views/emails/auth/reminder.blade.php b/app/views/emails/auth/reminder.blade.php index d92f2b3..323edf3 100755 --- a/app/views/emails/auth/reminder.blade.php +++ b/app/views/emails/auth/reminder.blade.php @@ -4,10 +4,14 @@
-