web.php 923 B

1234567891011121314151617181920212223242526272829303132333435
  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. use App\Task;
  13. Route::get('/tasks', function () {
  14. $name = 'Fred';
  15. // $tasks = DB::table('tasks')->get();
  16. $tasks = Task::all();
  17. // Return a JSON response from the serialized results.
  18. // return $tasks;
  19. return view('tasks.index', compact('name', 'tasks'));
  20. });
  21. Route::get('/tasks/{task}', function ($id) {
  22. // $task = DB::table('tasks')->find($id);
  23. $task = Task::find($id);
  24. // Return a JSON response from the serialized results.
  25. // return $tasks;
  26. return view('tasks.show', compact('task'));
  27. });