效果图片
UserController.php代码
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Student;
class UserController extends Controller
{
public function index()
{
$name = "张云琪";
$age =19;
// $students=$this->students;
$students = Student::$students;
return view('info')->with(compact('name','age','students'));
dd("hhh");
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
dd("creat");
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
$stu =null;
// $students=$this->students;
$students = Student::$students;
foreach($students as $value){
if($value['xh']==$id){
$stu =$value;
}
}
return view('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)
{
//
}
public function showSome(){
$names="张红叶";
return view('admin.login')->with('name',$names)->with('age',20);
}
}
info.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{{asset('').'css/bootstrap.min.css'}}">
<title>Document</title>
</head>
<body>
<table class="table table-sm">
<thead>
<tr>
<th scope="col">编号</th>
<th scope="col">姓名</th>
<th scope="col">年级</th>
<th scope="col">专业</th>
<th scope="col">专业编号</th>
<th scope="col">班级</th>
<th scope="col">学习形式</th>
<th scope="col">性别</th>
</tr>
</thead>
<tbody>
@foreach ($students as $item )
@if ($loop->index%2)
<tr class="bgcolor">
@else
<tr>
@endif
<!-- <tr> -->
<th scope="row">{{$loop->index}}{{$item['id']}}</th>
<td>
<!-- <a href="{{url('useer/'.$item['xh'])}}">{ {$item['xingming']}}</a> -->
<a href="{{route('useer.show',$item['xh'])}}">{{$item['xingming']}}</a>
</td>
<td>{{$item['nianji']}}</td>
<td>{{$item['zhuanye']}}</td>
<td>{{$item['zhuanyebianhao']}}</td>
<td>{{$item['banji']}}</td>
<td>{{$item['xuexixingshi']}}</td>
<td>{{$item['xingbie']}}</td>
</tr>
@endforeach
<style type="text/css">
.bgcolor{
background: lightgreen;
}
</style>
</body>
</html>