![请添加图片描述](https://i-blog.csdnimg.cn/blog_migrate/ee02987bffc72bfa6ee6e94de6032331.png)
![](https://i-blog.csdnimg.cn/blog_migrate/baab5b6e988655a5583cd051970e8ba5.png)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class AddUserController extends Controller
{
public function test()
{
$users=DB::table('users')->get();
return view('allUsers',compact('users'));
}
public function create()
{
return view('regist');
}
public function store(Request $request)
{
$user=$request->only(['name','email','password']);
$res=DB::table('users')->insert($user);
dd($res);
}
public function update(Request $request, $id)
{
dd($id);
}
public function edit($id)
{
DB::table('users')->where('id', '=', $id)->delete();
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<table border="1">
<caption></caption>
<thead>
<tr>
<th>name</th><th>email</th><th>操作</th>
</tr>
</thead>
<tbody>
@foreach($users as $u)
<tr>
<td>{{$u->name}}</td><td>{{$u->email}}</td><td><a href="test/{{$u->id}}">修改</a>|
<a href="test/edit/{{$u->id}}">删除</a></td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>