web.php 801 B

1234567891011121314151617181920212223242526
  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. // Cannot cache a view result as such, as it contains a Closure, which is
  13. // not serializable.
  14. $this->get('/tasks', function () {
  15. $tasks = \App\Task::all();
  16. return view('welcome', compact('tasks'))->__toString();
  17. })->middleware('cache');
  18. $this->get('/tasks/first', function () {
  19. $tasks = [\App\Task::first()];
  20. return view('welcome', compact('tasks'))->__toString();
  21. })->middleware('cache');