摘要: 1,数据的删除包括【物理删除】和【软删除】2种,实际工作中以软删除比较多,类似 windows 上的回收站的功能。 找到 \resources\views\Admin\User\index.blade.php 管理员列表页的 删除 按钮,编辑 超链如下 <a href="#" onclick="bo 阅读全文
posted @ 2020-05-18 17:40 pensive2019 阅读(174) 评论(0) 推荐(0)
摘要: 1, App\Http\Requests\UserRequest.php 修改 rules() 方法 不检验是否与所编辑 id 所对应的用户名重复 public function rules() { $id = $this->route('id'); return [ "username" => ' 阅读全文
posted @ 2020-05-18 11:56 pensive2019 阅读(365) 评论(0) 推荐(0)
摘要: 1,\resources\views\Admin\User\edit.blade.php 的表单 form 的 action 修改为带ID参数的目的地址,method 用 post 方式 <form class="form-horizontal" role="form" action="{{rout 阅读全文
posted @ 2020-05-18 11:37 pensive2019 阅读(217) 评论(0) 推荐(0)
摘要: 一、创建编辑页面 1,编辑 App\Http\Controllers\Controller\UserController.php 的 edit() 方法 public function edit(int $id){//$id是接收到的ID $user = User::find($id);//通过ID 阅读全文
posted @ 2020-05-17 13:57 pensive2019 阅读(173) 评论(0) 推荐(0)
摘要: 1,在命令行 新建 App\Http\Requests\UserRequest.php 用户表单检验文件 php artisan make:request UserRequest 2,编辑上一步生成的 UserRequest.php 如下 <?php namespace App\Http\Reque 阅读全文
posted @ 2020-05-17 01:19 pensive2019 阅读(221) 评论(0) 推荐(0)
摘要: 1,修改完善 App\Http\Controllers\Admin\UserController.php 的 addSave() 方法,增加密码加密过程 public function addSave(Request $request){//Request $request 依赖注入 //dd($r 阅读全文
posted @ 2020-05-16 17:35 pensive2019 阅读(187) 评论(0) 推荐(0)
摘要: 1,\resources\views\Admin\User\add.blade.php 修改其中的form提交的目的地址 {{route('admin.user.add')}} 和给form添加 @csrf 如下所示: 2,App\Http\Controllers\Admin\UserControl 阅读全文
posted @ 2020-05-16 16:51 pensive2019 阅读(190) 评论(0) 推荐(0)
摘要: 1,App\Http\Controllers\Admin\UserController.php 编辑 add() 方法 public function add(){ return view('admin.user.add'); } 2,\resources\views\Admin\User\ 下新建 阅读全文
posted @ 2020-05-16 15:10 pensive2019 阅读(254) 评论(0) 推荐(0)
摘要: 1,获取用户数和分页,在 App\Http\Controllers\Admin\UserController.php 修改index()方法为 public function index(){ $data = User::paginate(3);//获取用户表数据并分页,每页展示 3 条记录 ret 阅读全文
posted @ 2020-05-16 12:02 pensive2019 阅读(271) 评论(0) 推荐(0)
摘要: 1,App\Http\Controllers\Admin\UserController.php的index()方法改为 public function index(){ return view('admin.user.index'); } 2,\resources\views\Admin 下新建 U 阅读全文
posted @ 2020-05-16 11:13 pensive2019 阅读(378) 评论(0) 推荐(0)