这是我从数据库中获取数据以传递到审阅页面的代码。但问题是在装载完成之前需要1分30秒或2-3分钟。
$province = $this->getProvince(); // Get Province Library
$cityPostalCode = $this->getCityPostalCode($id = null); // Get City Library
$occupations = $this->getOccupations(); // Get Province Library
$schoolname = $this->getSchoolname(); // Get Schoolname Library
return view('pages.frontend.review', compact('data',
'province',
'cityPostalCode',
'occupation',
'schoolname')
);
这是我在数据库中获取每个数据的代码
对于省
protected function getProvince(){
$province = Db::table('address_library')->select('province',
'province_code')->distinct()->get(); return $province;
}
适用于City Postal Code
protected function getCityPostalCode($id){
if(!empty($id)){
$cityPostalCode = Db::table('address_library')
->select('province_code','city','postal_code')
->where('province_code','=',$id)
->distinct('postal_code')
->get(); }
else {
$cityPostalCode = Db::table('address_library')
->select('province_code','city','postal_code')
->distinct('postal_code')
->get();
}
return $cityPostalCode;
}
职业
protected function getOccupations(){
$occupation_library = Db::table('occupation_library')
->select('id', 'title')
->orderBy('id', 'ASC')
->distinct()
->get();
return $occupation_library;
}
学校名称
protected function getSchoolname(){
$schoolname = Db::table('schoolname_library')
->select('code', 'name')
->orderBy('id', 'ASC')
->get();
return $schoolname;
}
在加载页面之前需要1分30秒或2分钟