web.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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('/', function () {
  13. $data = [
  14. ["id" => 1, "login" => "vasya"],
  15. ["id" => 2, "login" => "petya"],
  16. ["id" => 3, "login" => "kolya"],
  17. ["id" => 4, "login" => "nasimi"],
  18. ];
  19. //return $data;
  20. return view('welcome', ['aaa' => 'bbbb' ,'userList' => $data]);
  21. });
  22. Route::get('/about', function () {
  23. return ;
  24. });
  25. Route::get('/tag/{text}', function (String $text) {
  26. $tag = \App\Tag::where('tag', $text)->first();
  27. return $tag->posts;
  28. });
  29. Route::get('/multiply_table/{width}/{height}', function ($width, $height) {
  30. $arr = [];
  31. for ($y=1;$y<=$height;$y++){
  32. $arr[] = [];
  33. for ($x=1;$x<=$width;$x++){
  34. $arr[$y -1][$x -1] = $x * $y;
  35. }
  36. }
  37. return view('multiply_table', ["table" => $arr]);
  38. })->where(['width' =>'[0-9]+', 'height' =>'\d+'] )
  39. ->name('multiply');
  40. Route::resource('/cntrl',"SomeController");
  41. Route::resource('/comment',"CommentController");