Merge pull request 'Added filter logic in asrs item validations resource page' (#648) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #648
This commit was merged in pull request #648.
This commit is contained in:
@@ -215,7 +215,7 @@ class AsrsItemValidationResource extends Resource
|
|||||||
if ($userHas && strlen($userHas) > 0) {
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
} else {
|
} else {
|
||||||
return Plant::whereHas('vehicleEntries', function ($query) {
|
return Plant::whereHas('asrsItemValidations', function ($query) {
|
||||||
$query->whereNotNull('id');
|
$query->whereNotNull('id');
|
||||||
})->orderBy('code')->pluck('name', 'id');
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
}
|
}
|
||||||
@@ -247,7 +247,6 @@ class AsrsItemValidationResource extends Resource
|
|||||||
Select::make('status')
|
Select::make('status')
|
||||||
->label('Status')
|
->label('Status')
|
||||||
->reactive()
|
->reactive()
|
||||||
->searchable()
|
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
|
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
@@ -276,9 +275,27 @@ class AsrsItemValidationResource extends Resource
|
|||||||
->native(false),
|
->native(false),
|
||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
|
|
||||||
|
$status = $data['status'] ?? 'NotUpdated';
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['Plant']) && empty($data['item_code']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
// if (empty($data['Plant']) && empty($data['item_code']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
// // return $query->whereRaw('1 = 0');
|
||||||
|
// $query->where('status', 'NotUpdated');
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (
|
||||||
|
empty($data['Plant']) &&
|
||||||
|
empty($data['item_code']) &&
|
||||||
|
empty($data['status']) &&
|
||||||
|
empty($data['created_from']) &&
|
||||||
|
empty($data['created_to'])
|
||||||
|
) {
|
||||||
|
// $query->where('status', 'NotUpdated');
|
||||||
|
$query->where(function ($q) {
|
||||||
|
$q->where('status', 'NotUpdated')
|
||||||
|
->orWhereNull('status')
|
||||||
|
->orWhere('status', '');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
@@ -295,8 +312,17 @@ class AsrsItemValidationResource extends Resource
|
|||||||
$query->where('item_code', 'like', '%'.$data['item_code'].'%');
|
$query->where('item_code', 'like', '%'.$data['item_code'].'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['status'])) {
|
if (!empty($data['status'])) {
|
||||||
$query->where('status', $data['status']);
|
|
||||||
|
if ($data['status'] == 'NotUpdated') {
|
||||||
|
$query->where(function ($q) {
|
||||||
|
$q->where('status', 'NotUpdated')
|
||||||
|
->orWhereNull('status')
|
||||||
|
->orWhere('status', '');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$query->where('status', $data['status']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user