Php 使用带有参数Css的where条件后,在laravel中不起作用
我试图在调用此函数后使用where condition with parameter列出数据库详细信息CSS不工作,但所有数据都已正确列出,并且没有参数,CSS工作正常 web.phpPhp 使用带有参数Css的where条件后,在laravel中不起作用,php,html,css,laravel,web-deployment,Php,Html,Css,Laravel,Web Deployment,我试图在调用此函数后使用where condition with parameter列出数据库详细信息CSS不工作,但所有数据都已正确列出,并且没有参数,CSS工作正常 web.php Route::get('/viwelist/{id}','Front\SISProfileController@check'); 控制器 class SISProfileController extends Controller { public function check($district){
Route::get('/viwelist/{id}','Front\SISProfileController@check');
控制器
class SISProfileController extends Controller
{
public function check($district){
$list = SISAccount::all()->where('District', '==', $district);
//dd($list->all());
return view('Front.listSIS', compact('list'));
}
}
链接
<a href="{{ URL('/viwelist/'.'districtname')}}">click</a>
您要做的是从数据库中获取所有元素,并通过
Collection::where
方法检查该条件,如果数据库中有大量数据,这将导致很多问题。相反,您应该直接在数据库上使用where
方法,然后仅返回这些记录,因此您应该执行以下操作:
$list = SISAccount::where('District', '=', $district)->get(); //to get back a Collection with all the records
$list = SISAccount::where('District', '=', $district)->first(); //to get only the first record, like if District is your primary key
css问题可能是因为您在头上放置了一个相对链接作为css文件的位置,而您应该有类似于
/asset/css.css
的内容,所以在开始时有一个/
,问题在我的css链接中,我就是这样处理的,问题解决了{Html::style]('assets/css/bootstrap.min.css')}
,无论如何,您的答案非常有用。很好,将其设置为答案以关闭此问题