博客列表 >控制器和路由

控制器和路由

橙絮圆
橙絮圆原创
2021年09月14日 11:50:30648浏览

控制器和路由

作业标题:0903作业
作业内容:1.创建相应控制器和路由 2.预习Blade 模板

  1. 1.创建相应控制器和路由

路由

  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Web Routes
  6. |--------------------------------------------------------------------------
  7. |
  8. | Here is where you can register web routes for your application. These
  9. | routes are loaded by the RouteServiceProvider within a group which
  10. | contains the "web" middleware group. Now create something great!
  11. |
  12. */
  13. //会员操作
  14. //增
  15. //修改
  16. //删除
  17. //查看
  18. //资源路由
  19. //Route::resource('/admin/home/user',\App\Http\Controllers\test\ResourceController::class);
  20. //
  21. // Route::resource('/admin/user',\App\Http\Controllers\test\ResourceController::class)
  22. // ->except([
  23. // 'index',
  24. // 'show',
  25. // 'create'
  26. // ]);
  27. //命名资源路由
  28. // Route::resource('/admin/home/phpcn',\App\Http\Controllers\test\ResourceController::class)
  29. // ->names([
  30. // //方法名=>要更换的路由名称
  31. // 'store'=>'nihao.store'
  32. // ]);
  33. // //补充资源路由
  34. // Route::get('/admin/home/phpcn/sigle/{id?}',[\App\Http\Controllers\test\ResourceController::class,'sigle']);
  35. // //修改命名资源路由的参数名称
  36. // Route::resource('/admin/home/haha',\App\Http\Controllers\test\ResourceController::class)
  37. // ->parameters([
  38. // 'haha'=>'name'
  39. // ]);
  40. //项目后台路由
  41. Route::get('/admin/home/welcome',[\App\Http\Controllers\Admin\IndexController::class,'index'])
  42. ->name('admin.index');
  43. //会员资源路由
  44. Route::resource('/admin/home/user',\App\Http\Controllers\Admin\UserController::class);
  45. //会员权限资源路由
  46. Route::resource('/admin/home/purchase',\App\Http\Controllers\Admin\PurchaseController::class)
  47. 控制器
  48. ```php
  49. <?php
  50. namespace App\Http\Controllers\Admin;
  51. use App\Http\Controllers\Controller;
  52. use Illuminate\Http\Request;
  53. class IndexController extends Controller
  54. {
  55. //
  56. }
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. class LoginController extends Controller
  6. {
  7. //
  8. }
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. class OrderController extends Controller
  6. {
  7. //
  8. }
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. class PurchaseController extends Controller
  6. {
  7. /**
  8. * Display a listing of the resource.
  9. *
  10. * @return \Illuminate\Http\Response
  11. */
  12. public function index()
  13. {
  14. //
  15. }
  16. /**
  17. * Show the form for creating a new resource.
  18. *
  19. * @return \Illuminate\Http\Response
  20. */
  21. public function create()
  22. {
  23. //
  24. }
  25. /**
  26. * Store a newly created resource in storage.
  27. *
  28. * @param \Illuminate\Http\Request $request
  29. * @return \Illuminate\Http\Response
  30. */
  31. public function store(Request $request)
  32. {
  33. //
  34. }
  35. /**
  36. * Display the specified resource.
  37. *
  38. * @param int $id
  39. * @return \Illuminate\Http\Response
  40. */
  41. public function show($id)
  42. {
  43. //
  44. }
  45. /**
  46. * Show the form for editing the specified resource.
  47. *
  48. * @param int $id
  49. * @return \Illuminate\Http\Response
  50. */
  51. public function edit($id)
  52. {
  53. //
  54. }
  55. /**
  56. * Update the specified resource in storage.
  57. *
  58. * @param \Illuminate\Http\Request $request
  59. * @param int $id
  60. * @return \Illuminate\Http\Response
  61. */
  62. public function update(Request $request, $id)
  63. {
  64. //
  65. }
  66. /**
  67. * Remove the specified resource from storage.
  68. *
  69. * @param int $id
  70. * @return \Illuminate\Http\Response
  71. */
  72. public function destroy($id)
  73. {
  74. //
  75. }
  76. }
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. class QuestionController extends Controller
  6. {
  7. /**
  8. * Display a listing of the resource.
  9. *
  10. * @return \Illuminate\Http\Response
  11. */
  12. public function index()
  13. {
  14. //
  15. }
  16. /**
  17. * Show the form for creating a new resource.
  18. *
  19. * @return \Illuminate\Http\Response
  20. */
  21. public function create()
  22. {
  23. //
  24. }
  25. /**
  26. * Store a newly created resource in storage.
  27. *
  28. * @param \Illuminate\Http\Request $request
  29. * @return \Illuminate\Http\Response
  30. */
  31. public function store(Request $request)
  32. {
  33. //
  34. }
  35. /**
  36. * Display the specified resource.
  37. *
  38. * @param int $id
  39. * @return \Illuminate\Http\Response
  40. */
  41. public function show($id)
  42. {
  43. //
  44. }
  45. /**
  46. * Show the form for editing the specified resource.
  47. *
  48. * @param int $id
  49. * @return \Illuminate\Http\Response
  50. */
  51. public function edit($id)
  52. {
  53. //
  54. }
  55. /**
  56. * Update the specified resource in storage.
  57. *
  58. * @param \Illuminate\Http\Request $request
  59. * @param int $id
  60. * @return \Illuminate\Http\Response
  61. */
  62. public function update(Request $request, $id)
  63. {
  64. //
  65. }
  66. /**
  67. * Remove the specified resource from storage.
  68. *
  69. * @param int $id
  70. * @return \Illuminate\Http\Response
  71. */
  72. public function destroy($id)
  73. {
  74. //
  75. }
  76. }
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. class UserController extends Controller
  6. {
  7. //
  8. }

```

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议