$query = Amodel::query();;
$query->with("user");
if (isset($params['username']) && filled($params['username'])) {
$username = $params["username"];
$query->whereHas("user", function ($query) use ($username) {
$query->where('username', $username);
});
}
Amodel 關聯user 查詢條件需要查user表的username