php - 无需登录的搜索功能
问题描述
这是一个搜索功能,应登录以查看搜索刀片。我想在不需要学生登录的情况下显示搜索刀片并允许任何人使用此功能
这是我在控制器中的搜索功能
public function search()
{
$q = Input::get ( 'q' );
if($q != ""){
$student = Student::where ( 'uniid', 'LIKE', '%' . $q . '%' )->get();
if (count ( $student ) > 0)
return view ( 'search' )->withDetails ( $student )->withQuery ( $q );
else
return view ( 'search' )->withMessage ( 'not fount' );
}
return view ( 'search' )->withMessage ( 'write the number want to search' );
}
这是我的搜索刀片
<!DOCTYPE html>
<html>
<head>
<title>Search</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<form action="/search" method="POST" role="search">
{{ csrf_field() }}
<div class="input-group">
<input type="text" class="form-control" name="q"
placeholder="search.."> <span class="input-group-btn">
<button type="submit" class="btn btn-default">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
<div class="container">
@if(isset($details))
<table class="table table-striped">
<thead>
<tr>
<th> unique id</th>
<th> order statuse</th>
</tr>
</thead>
<tbody>
@foreach($details as $request)
<tr>
<td>{{$request->uniid}}</td>
<td>{{$request->status->name}}</td>
</tr>
@endforeach
</tbody>
</table>
@elseif(isset($message))
<p>{{ $message }}</p>
@endif
</div>
</body>
</html>
解决方案
推荐阅读
- php - PHP while循环在发送后中断
- python - Python触发/模拟自定义浏览器协议
- r - 从 excel 电子表格在 R 中制作出版质量表
- javascript - 如何使用 JavaScript 获取设备的最准确 GPS 坐标?
- android - apollo-android 对 express-graphql 的请求总是导致 http 400
- r - 完成下一个专栏系列
- python - 将轮廓检测到方法 cv2.Circle
- excel - VBA-单元格是一个数字然后复制它
- javascript - 闪亮中的零索引问题和过滤问题
- css - 如何在没有滚动条的情况下构建 Ionic 应用程序