mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-17 03:51:06 +01:00
Filtro per ragione_sociale resource anagrafiche
This commit is contained in:
parent
bfd7e27556
commit
c9855a56ec
@ -56,9 +56,7 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface
|
|||||||
'an_anagrafiche.note',
|
'an_anagrafiche.note',
|
||||||
'an_anagrafiche.idzona',
|
'an_anagrafiche.idzona',
|
||||||
'an_anagrafiche.deleted_at'
|
'an_anagrafiche.deleted_at'
|
||||||
)->skip($request['page'] * $request['length'])
|
)->orderBy('an_anagrafiche.ragione_sociale');
|
||||||
->limit($request['length'])
|
|
||||||
->orderBy('an_anagrafiche.ragione_sociale');
|
|
||||||
|
|
||||||
$filters = [];
|
$filters = [];
|
||||||
if ($request['resource'] != 'anagrafiche') {
|
if ($request['resource'] != 'anagrafiche') {
|
||||||
@ -70,6 +68,7 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface
|
|||||||
// Filtri da richiesta API
|
// Filtri da richiesta API
|
||||||
$allow_list = [
|
$allow_list = [
|
||||||
'idanagrafica',
|
'idanagrafica',
|
||||||
|
'ragione_sociale',
|
||||||
];
|
];
|
||||||
$conditions = array_intersect_key((array) $request['where'], array_flip($allow_list));
|
$conditions = array_intersect_key((array) $request['where'], array_flip($allow_list));
|
||||||
|
|
||||||
@ -78,6 +77,11 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface
|
|||||||
$query = $query->whereIn('an_anagrafiche.idanagrafica', (array) $conditions['idanagrafica']);
|
$query = $query->whereIn('an_anagrafiche.idanagrafica', (array) $conditions['idanagrafica']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filtro per Ragione sociale
|
||||||
|
if (!empty($conditions['ragione_sociale'])) {
|
||||||
|
$query = $query->where('an_anagrafiche.ragione_sociale','like', '%'.$conditions['ragione_sociale'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
// Filtri aggiuntivi predefiniti
|
// Filtri aggiuntivi predefiniti
|
||||||
$module = Modules::get('Anagrafiche');
|
$module = Modules::get('Anagrafiche');
|
||||||
$additionals = Modules::getAdditionals($module->id, false);
|
$additionals = Modules::getAdditionals($module->id, false);
|
||||||
@ -90,7 +94,10 @@ class Anagrafiche extends Resource implements RetrieveInterface, CreateInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'results' => $query->get()->toArray(),
|
'results' => $query->skip($request['page'] * $request['length'])
|
||||||
|
->limit($request['length'])
|
||||||
|
->get()->toArray(),
|
||||||
|
'total-count' => $query->count(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user