userController.php
在这里插入<?php
namespace App\Http\Controllers;
use App\Http\Controllers\students;
use Illuminate\Http\Request;
class userController1 extends Controller
{
public function index()
{
}
public function store(Request $request)
{
}
public function show($id)
{
$stu=null;
$students=students::$students;
foreach($students as $value){
if($value['xh']==$id){
$stu=$value;
}
}
return view('admin.detail',compact("stu"));
}
public function edit($id)
{
}
public function update(Request $request, $id)
{
}
public function destroy($id)
{
}
}
zxy.blade.php
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<link rel="stylesheet" href="{{asset('css/bootstrap.min.css')}}">
</head>
<body>
<h2>学生信息</h2>
@if(empty($stu))
<h2>没有学生信息</h2>
@else
<div class="row">
<div class="col-md-8">
<table class="table table-dark">
<tr>
<th>编号</th>
<th>学号</th>
<th>姓名</th>
<th>性别</th>
<th>班级</th>
<th>专业</th>
<th>年级</th>
<th>学习方式</th>
</tr>
<tr>
<td>{{$stu['id']}}</td>
<td>{{$stu['xh']}}</td>
<td> {{$stu['xingming']}}</td>
<td>{{$stu['xingbie']}}</td>
<td>{{$stu['banji']}}</td>
<td>{{$stu['zhuanye']}}</td>
<td>{{$stu['nianji']}}</td>
<td>{{$stu['xuexixingshi']}}</td>
</tr>
</table>
</div>
@endif
</div>
</body>
</html>
web.php
Route::get('/user',[usercontroller::class,'index']);
Route::resource('/user',[userController::class]);
|