routes.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Application Routes
  5. |--------------------------------------------------------------------------
  6. |
  7. | Here is where you can register all of the routes for an application.
  8. | It's a breeze. Simply tell Laravel the URIs it should respond to
  9. | and give it the Closure to execute when that URI is requested.
  10. |
  11. */
  12. Route::model('task', 'Task');
  13. Route::get('/', 'TasksController@home');
  14. Route::get('/create', 'TasksController@create');
  15. Route::get('/edit/{task}', 'TasksController@edit');
  16. Route::get('/delete/{task}', 'TasksController@delete');
  17. Route::post('/delete', 'TasksController@doDelete');
  18. Route::post('/create', 'TasksController@saveCreate');
  19. Route::post('/edit', 'TasksController@doEdit');
  20. Route::get('/about', function()
  21. {
  22. return View::make('about');
  23. });
  24. Route::get('/contact', function()
  25. {
  26. return View::make('contact');
  27. });
  28. Route::post('contact', function(){
  29. $data = Input::all();
  30. $rule = array(
  31. 'subject' => 'required',
  32. 'message' => 'required'
  33. );
  34. $validator = Validator::make($data, $rule);
  35. if($validator->fails()){
  36. return Redirect::to('contact')->withErrors($validator)->withInput();
  37. }
  38. $emailcontent = array(
  39. 'subject' => $data['subject'],
  40. 'emailmessage' => $data['message']
  41. );
  42. Mail::send('emails.contactemail', $emailcontent, function($message)
  43. {
  44. $message->to('lifengtest@gmail.com')
  45. ->subject('Contact via Our Contact Form');
  46. });
  47. return 'Your message has been sent';
  48. });
  49. Route::get('task/{id}', 'TasksController@show')->where('id', '\d+');