博客列表 >后台页面(资源控制器与资源路由)

后台页面(资源控制器与资源路由)

橙絮圆
橙絮圆原创
2021年09月17日 22:15:16760浏览

后台页面(资源控制器与资源路由)

作业标题:0907作业
作业内容:完成项目后台页面

  1. 后台页面展示
    后台页面
  2. 资源路由代码
  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. //后台的路由文件
  4. // Route::get('/admin/home',function(){
  5. // dd('我来了');
  6. // });
  7. //定义后台分组
  8. Route::prefix('admin')->name('admin.')->group(function(){
  9. Route::get('home',function(){
  10. //dd('后台首页的显示',route('admin.index'));
  11. return view('admin.welcome');
  12. })->name('index');
  13. //添加对象资源路由
  14. Route::resource('home/user',\App\Http\Controllers\Admin\UserController::class);
  15. //添加权限管理路由
  16. Route::resource('home/purchase',\App\Http\Controllers\Admin\PurchaseController::class);
  17. //添加问题管理路由
  18. Route::resource('home/question',\App\Http\Controllers\Admin\QuestionController::class);
  19. //添加订单管理路由
  20. Route::resource('home/order',\App\Http\Controllers\Admin\OrderController::class);
  21. });
  1. 对象管理控制器代码
  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. * Display a listing of the resource.
  9. *
  10. * @return \Illuminate\Http\Response
  11. */
  12. public function index()
  13. {
  14. }
  15. /**
  16. * Show the form for creating a new resource.
  17. *
  18. * @return \Illuminate\Http\Response
  19. */
  20. public function create()
  21. {
  22. //显示添加页面
  23. return view('admin.users.add');
  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. //return view('admin.users.aud');
  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. return view('admin.users.list');
  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. return view('admin.users.edit');
  55. }
  56. /**
  57. * Update the specified resource in storage.
  58. *
  59. * @param \Illuminate\Http\Request $request
  60. * @param int $id
  61. * @return \Illuminate\Http\Response
  62. */
  63. public function update(Request $request, $id)
  64. {
  65. //
  66. }
  67. /**
  68. * Remove the specified resource from storage.
  69. *
  70. * @param int $id
  71. * @return \Illuminate\Http\Response
  72. */
  73. public function destroy($id)
  74. {
  75. //
  76. }
  77. }

4.订单管理控制器代码

  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. * 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. return view('admin.orders.add');
  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. return view('admin.orders.list');
  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. }

5.权限管理控制器代码

  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. return view('admin.purchase.add');
  25. }
  26. /**
  27. * Store a newly created resource in storage.
  28. *
  29. * @param \Illuminate\Http\Request $request
  30. * @return \Illuminate\Http\Response
  31. */
  32. public function store(Request $request)
  33. {
  34. //
  35. }
  36. /**
  37. * Display the specified resource.
  38. *
  39. * @param int $id
  40. * @return \Illuminate\Http\Response
  41. */
  42. public function show($id)
  43. {
  44. return view('admin.purchase.list');
  45. }
  46. /**
  47. * Show the form for editing the specified resource.
  48. *
  49. * @param int $id
  50. * @return \Illuminate\Http\Response
  51. */
  52. public function edit($id)
  53. {
  54. //
  55. }
  56. /**
  57. * Update the specified resource in storage.
  58. *
  59. * @param \Illuminate\Http\Request $request
  60. * @param int $id
  61. * @return \Illuminate\Http\Response
  62. */
  63. public function update(Request $request, $id)
  64. {
  65. //
  66. }
  67. /**
  68. * Remove the specified resource from storage.
  69. *
  70. * @param int $id
  71. * @return \Illuminate\Http\Response
  72. */
  73. public function destroy($id)
  74. {
  75. //
  76. }
  77. }

6.问题管理控制代码

  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. return view('admin.question.add');
  25. }
  26. /**
  27. * Store a newly created resource in storage.
  28. *
  29. * @param \Illuminate\Http\Request $request
  30. * @return \Illuminate\Http\Response
  31. */
  32. public function store(Request $request)
  33. {
  34. //
  35. }
  36. /**
  37. * Display the specified resource.
  38. *
  39. * @param int $id
  40. * @return \Illuminate\Http\Response
  41. */
  42. public function show($id)
  43. {
  44. //
  45. return view('admin.question.list');
  46. }
  47. /**
  48. * Show the form for editing the specified resource.
  49. *
  50. * @param int $id
  51. * @return \Illuminate\Http\Response
  52. */
  53. public function edit($id)
  54. {
  55. //
  56. }
  57. /**
  58. * Update the specified resource in storage.
  59. *
  60. * @param \Illuminate\Http\Request $request
  61. * @param int $id
  62. * @return \Illuminate\Http\Response
  63. */
  64. public function update(Request $request, $id)
  65. {
  66. //
  67. }
  68. /**
  69. * Remove the specified resource from storage.
  70. *
  71. * @param int $id
  72. * @return \Illuminate\Http\Response
  73. */
  74. public function destroy($id)
  75. {
  76. //
  77. }
  78. }

8.左侧菜单部分代码

  1. <li class="nav-item">
  2. <a href="#" class="nav-link">
  3. <i class="nav-icon fas fa-copy"></i>
  4. <p>
  5. 对象管理
  6. <i class="fas fa-angle-left right"></i>
  7. </p>
  8. </a>
  9. <ul class="nav nav-treeview">
  10. <li class="nav-item">
  11. <a href="{{ route('admin.user.create')}}" class="nav-link">
  12. <i class="far fa-circle nav-icon"></i>
  13. <p>添加对象</p>
  14. </a>
  15. </li>
  16. <li class="nav-item">
  17. <a href="{{ route('admin.user.show','user')}}" class="nav-link">
  18. <i class="far fa-circle nav-icon"></i>
  19. <p>对象列表</p>
  20. </a>
  21. </li>
  22. <li class="nav-item">
  23. <a href="{{ route('admin.user.edit','user')}}" class="nav-link">
  24. <i class="far fa-circle nav-icon"></i>
  25. <p>审核对象</p>
  26. </a>
  27. </li>
  28. </ul>
  29. </li>
  30. <li class="nav-item">
  31. <a href="#" class="nav-link">
  32. <i class="nav-icon fas fa-chart-pie"></i>
  33. <p>
  34. 权限管理
  35. <i class="right fas fa-angle-left"></i>
  36. </p>
  37. </a>
  38. <ul class="nav nav-treeview">
  39. <li class="nav-item">
  40. <a href="{{ route('admin.purchase.create')}}" class="nav-link">
  41. <i class="far fa-circle nav-icon"></i>
  42. <p>设置权限</p>
  43. </a>
  44. </li>
  45. <li class="nav-item">
  46. <a href="{{ route('admin.purchase.show','user')}}" class="nav-link">
  47. <i class="far fa-circle nav-icon"></i>
  48. <p>查看已有权限</p>
  49. </a>
  50. </li>
  51. </ul>
  52. </li>
  53. <li class="nav-item">
  54. <a href="#" class="nav-link">
  55. <i class="nav-icon fas fa-tree"></i>
  56. <p>
  57. 问题管理
  58. <i class="fas fa-angle-left right"></i>
  59. </p>
  60. </a>
  61. <ul class="nav nav-treeview">
  62. <li class="nav-item">
  63. <a href="{{ route('admin.question.create')}}" class="nav-link">
  64. <i class="far fa-circle nav-icon"></i>
  65. <p>设置问题</p>
  66. </a>
  67. </li>
  68. <li class="nav-item">
  69. <a href="{{ route('admin.question.show','user')}}" class="nav-link">
  70. <i class="far fa-circle nav-icon"></i>
  71. <p>查看问题</p>
  72. </a>
  73. </li>
  74. </ul>
  75. </li>
  76. <li class="nav-item">
  77. <a href="#" class="nav-link">
  78. <i class="nav-icon fas fa-edit"></i>
  79. <p>
  80. 订单管理
  81. <i class="fas fa-angle-left right"></i>
  82. </p>
  83. </a>
  84. <ul class="nav nav-treeview">
  85. <li class="nav-item">
  86. <a href="{{ route('admin.order.create')}}" class="nav-link">
  87. <i class="far fa-circle nav-icon"></i>
  88. <p>查看订单</p>
  89. </a>
  90. </li>
  91. <li class="nav-item">
  92. <a href="{{ route('admin.order.show','user')}}" class="nav-link">
  93. <i class="far fa-circle nav-icon"></i>
  94. <p>订单统计</p>
  95. </a>
  96. </li>
  97. </ul>
  98. </li>

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