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) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('vehicleEntries', function ($query) {
|
||||
return Plant::whereHas('asrsItemValidations', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
@@ -247,7 +247,6 @@ class AsrsItemValidationResource extends Resource
|
||||
Select::make('status')
|
||||
->label('Status')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
|
||||
$plantId = $get('Plant');
|
||||
@@ -276,9 +275,27 @@ class AsrsItemValidationResource extends Resource
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
|
||||
$status = $data['status'] ?? 'NotUpdated';
|
||||
// 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'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
// if (empty($data['Plant']) && empty($data['item_code']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
// // 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'])) {
|
||||
@@ -295,8 +312,17 @@ class AsrsItemValidationResource extends Resource
|
||||
$query->where('item_code', 'like', '%'.$data['item_code'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['status'])) {
|
||||
$query->where('status', $data['status']);
|
||||
if (!empty($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'])) {
|
||||
|
||||
Reference in New Issue
Block a user