📅  最后修改于: 2022-03-11 14:54:52.150000             🧑  作者: Mango
$query = ""
if ($request->has('country'){
$query = Post::with("country")->whereHas("country",function($q) use($request){
$q->where("name","=",$request->country);
})->get()
}else{
$query = Post::with("country")->get();
}