代码1
public function index(Request $request)
{
$posts = NewJob::orderBy('won', 'desc')->where('progress' , 'forwarded')->paginate(5);
$clients = DB::select('select * from client_infos');
if ($request->ajax()){
return view('Admin.NewForwardedEntry.ajax', compact('posts', 'clients'));
}
else{
return view('Admin.NewForwardedEntry.newjob', compact('posts', 'clients'));
}
}
代码2
public function index(Request $request)
{
$posts = DB::table('new_jobs')
->select('id', 'won', 'proj_name', 'department', 'district', 'time_estimate', 'proj_cost', 'proj_date', 'client_id', 'created_at', 'updated_at'**strong text**)
->orderBy('won', 'desc')
->where('progress', 'forwarded')
->paginate(5);
$clients = DB::select('select * from client_infos');
if ($request->ajax()){
return view('Admin.NewForwardedEntry.ajax', compact('posts', 'clients'));
}
else{
return view('Admin.NewForwardedEntry.newjob', compact('posts', 'clients'));
}
}
代码1正常运行,但是我不明白为什么代码2无法正常工作?
我正在更改此代码,因为我必须使用两个表 New_jobs 和 client_infos 来获取数据,其中客户信息应该通过new_jobs来获取。