web.php 847 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Web Routes
  5. |--------------------------------------------------------------------------
  6. |
  7. | Here is where you can register web routes for your application. These
  8. | routes are loaded by the RouteServiceProvider within a group which
  9. | contains the "web" middleware group. Now create something great!
  10. |
  11. */
  12. Route::get('/tasks', function () {
  13. $name = 'Fred';
  14. $tasks = DB::table('tasks')->get();
  15. // Return a JSON response from the serialized results.
  16. // return $tasks;
  17. return view('tasks.index', compact('name', 'tasks'));
  18. });
  19. Route::get('/tasks/{task}', function ($id) {
  20. $task = DB::table('tasks')->find($id);
  21. // Return a JSON response from the serialized results.
  22. // return $tasks;
  23. return view('tasks.show', compact('task'));
  24. });