|
13 | 13 | |
|
14 | 14 | */
|
15 | 15 |
|
16 |
| -App::error(function(ModelNotFoundException $e) |
| 16 | +// General Routes |
| 17 | + |
| 18 | +Route::get('/', function() |
17 | 19 | {
|
18 |
| - return Response::view('404', array(), 404); |
| 20 | + return View::make('index'); |
19 | 21 | });
|
20 | 22 |
|
21 |
| -App::missing(function($exception) |
| 23 | +Route::get('about', function() |
22 | 24 | {
|
23 |
| - return Response::view('404', array(), 404); |
| 25 | + return Response::json(Array('name'=>'GurbaniDB','version'=>'1.0.0')); |
24 | 26 | });
|
25 | 27 |
|
26 |
| -Route::get('/', function() |
| 28 | +// App Routes |
| 29 | + |
| 30 | +Route::get('scripture/page/{id?}', function($id = 1) |
27 | 31 | {
|
28 |
| - return Response::json(Array('name'=>'GurbaniDB','version'=>'1.0.0')); |
| 32 | + // Return the given page in the scripture, with translation and transliteration |
| 33 | + $data = Scripture::where('page', '=', $id)->get(); |
| 34 | + |
| 35 | + return Response::json($data); |
29 | 36 | });
|
30 | 37 |
|
31 |
| -Route::get('random', function() |
| 38 | +Route::get('scripture/hymn/{id?}', function($id = 1) |
32 | 39 | {
|
33 |
| - $data = Scripture::find(800)->melody; |
| 40 | + // Return the given hymn in the scripture, with translation and transliteration |
| 41 | + $data = Scripture::where('hymn', '=', $id)->get(); |
| 42 | + foreach($data as $hymn){ |
| 43 | + $hymn['melody'] = json_decode((String)Scripture::find($hymn->id)->melody); |
| 44 | + $hymn['author'] = json_decode((String)Scripture::find($hymn->id)->author); |
| 45 | + $hymn['language'] = json_decode((String)Scripture::find($hymn->id)->language); |
| 46 | + } |
34 | 47 | return Response::json($data);
|
35 | 48 | });
|
36 | 49 |
|
37 | 50 | Route::get('scripture/{id?}', function($id = 1)
|
38 | 51 | {
|
| 52 | + // Return the given line in the scripture |
39 | 53 | $data = Scripture::where('id', '=', $id)->firstOrFail();
|
40 | 54 | $data['melody'] = json_decode((String)Scripture::find($id)->melody);
|
41 | 55 | $data['author'] = json_decode((String)Scripture::find($id)->author);
|
|
53 | 67 | return Response::json($data);
|
54 | 68 | });
|
55 | 69 |
|
| 70 | +Route::get('random', function() |
| 71 | +{ |
| 72 | + // Returns a random hymn for the day |
| 73 | + // $data = Scripture::find(rand(0,60403)); |
| 74 | + // return Response::json($data); |
| 75 | +}); |
| 76 | + |
56 | 77 | Route::get('melody', function()
|
57 | 78 | {
|
58 | 79 | $data = Melody::all();
|
|
94 | 115 |
|
95 | 116 | return Response::json($data);
|
96 | 117 | });
|
| 118 | + |
| 119 | +// Error Routes |
| 120 | + |
| 121 | +App::error(function(ModelNotFoundException $e) |
| 122 | +{ |
| 123 | + return Response::view('404', array(), 404); |
| 124 | +}); |
| 125 | + |
| 126 | +App::missing(function($exception) |
| 127 | +{ |
| 128 | + return Response::view('404', array(), 404); |
| 129 | +}); |
0 commit comments