userController.php
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\students;
use Illuminate\Http\Request;
class userController1 extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
// dd("store");
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
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"));
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
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]);