字符串的查询用!empty判断

This commit is contained in:
邓皓元 2019-02-22 15:58:42 +08:00
parent 5793e63050
commit 0bd711d276
6 changed files with 14 additions and 14 deletions

View File

@ -60,8 +60,8 @@ class CompanyRepository extends Repository
$this->model = $this->model->whereIn('id', $conditions['id']);
}
if (isset($conditions['name'])) {
$this->model = $this->model->where('name', $conditions['name']);
if (!empty($conditions['name'])) {
$this->model = $this->model->where('name', 'like', "%{$conditions['name']}%");
}
if (isset($conditions['status'])) {

View File

@ -57,13 +57,13 @@ trait OrderCardConcern
$query->where('unit_price', $conditions['unit_price']);
}
if (isset($conditions['company_name'])) {
if (!empty($conditions['company_name'])) {
$query->whereHas('company', function ($relation) use ($conditions) {
$relation->withTrashed()->where('name', $conditions['company_name']);
});
}
if (isset($conditions['package_name'])) {
if (!empty($conditions['package_name'])) {
$query->whereHas('package', function ($relation) use ($conditions) {
$relation->withTrashed()->where('name', $conditions['package_name']);
});

View File

@ -62,11 +62,11 @@ class FlowPoolRepository extends Repository
$this->model = $this->model->where('carrier_operator', $conditions['carrier_operator']);
}
if (isset($conditions['name'])) {
if (!empty($conditions['name'])) {
$this->model = $this->model->where('name', 'like', "%{$conditions['name']}%");
}
if (isset($conditions['company_name'])) {
if (!empty($conditions['company_name'])) {
$this->model = $this->model->whereHas('company', function ($relation) use ($conditions) {
$relation->withTrashed()->where('name', $conditions['company_name']);
});

View File

@ -76,8 +76,8 @@ class OrderRepository extends Repository
$query->whereIn('company_id', $conditions['company_id']);
}
if (isset($conditions['sn'])) {
$query->where('sn', $conditions['sn']);
if (!empty($conditions['sn'])) {
$query->where('sn', "%{$conditions['sn']}%");
}
if (isset($conditions['order_status'])) {
@ -98,13 +98,13 @@ class OrderRepository extends Repository
$query->where('pay_channel', $conditions['pay_channel']);
}
if (isset($conditions['company_name'])) {
if (!empty($conditions['company_name'])) {
$query->whereHas('company', function ($relation) use ($conditions) {
$relation->withTrashed()->where('name', $conditions['company_name']);
});
}
if (isset($conditions['package_name'])) {
if (!empty($conditions['package_name'])) {
$query->whereHas('package', function ($relation) use ($conditions) {
$relation->withTrashed()->where('name', $conditions['package_name']);
});

View File

@ -65,11 +65,11 @@ class PackageRepository extends Repository
$this->model = $this->model->where('type', $conditions['type']);
}
if (isset($conditions['sn'])) {
if (!empty($conditions['sn'])) {
$this->model = $this->model->where('sn', "%{$conditions['sn']}%");
}
if (isset($conditions['name'])) {
if (!empty($conditions['name'])) {
$this->model = $this->model->where('name', 'like', "%{$conditions['name']}%");
}

View File

@ -67,11 +67,11 @@ class ProductRepository extends Repository
$query->where('status', $conditions['status']);
}
if (isset($conditions['name'])) {
if (!empty($conditions['name'])) {
$query->where('name', 'like', "%{$conditions['name']}%");
}
if (isset($conditions['package_name'])) {
if (!empty($conditions['package_name'])) {
$query->whereHas('package', function ($relation) use ($conditions) {
$relation->withTrashed()->where('name', $conditions['package_name']);
});