routes.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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::get('/json', function()
  13. {
  14. return Response::json(array('message' => 'Hello, World!'));
  15. });
  16. Route::get('/plaintext', function()
  17. {
  18. return "Hello, World!";
  19. });
  20. Route::get('/query', function()
  21. {
  22. $queries = Input::get('queries', 1);
  23. if (!is_numeric($queries) || $queries <= 1) {
  24. $queries = 1;
  25. }
  26. else if ($queries > 500) {
  27. $queries = 500;
  28. }
  29. $worlds = array();
  30. for($i = 0; $i < $queries; $i++) {
  31. $worlds[] = DB::table('World')->find(mt_rand(1, 10000));
  32. }
  33. return Response::json($worlds);
  34. });
  35. Route::get('/db', function()
  36. {
  37. return Response::json(DB::table('World')->find(mt_rand(1, 10000)));
  38. });
  39. Route::get('/updates', function()
  40. {
  41. $queries = Input::get('queries', 1);
  42. if (!is_numeric($queries) || $queries <= 1) {
  43. $queries = 1;
  44. }
  45. else if ($queries > 500) {
  46. $queries = 500;
  47. }
  48. $worlds = array();
  49. for($i = 0; $i < $queries; $i++) {
  50. $id = mt_rand(1, 10000);
  51. $random_number = mt_rand(1, 10000);
  52. $world = DB::table('World')->find($id);
  53. $world->randomNumber = $random_number;
  54. DB::table('World')->where('id', $id)->update(['randomNumber' => $random_number]);
  55. $worlds[] = $world;
  56. }
  57. return Response::json($worlds);
  58. });
  59. Route::get('/fortunes', 'BenchController@fortunes');