mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-28 10:53:40 +03:00
Update the EA_Model::only method to use the array_fields function
This commit is contained in:
parent
98a0e07484
commit
54bc07f62a
1 changed files with 12 additions and 4 deletions
|
@ -169,14 +169,22 @@ class EA_Model extends CI_Model {
|
|||
/**
|
||||
* Only keep the requested fields of the provided record.
|
||||
*
|
||||
* @param array $record Record data.
|
||||
* @param array $record Record data (single or multiple records).
|
||||
* @param array $fields Requested field names.
|
||||
*/
|
||||
public function only(array &$record, array $fields)
|
||||
{
|
||||
$record = array_filter($record, function ($field) use ($fields) {
|
||||
return in_array($field, $fields);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
if (is_assoc($record))
|
||||
{
|
||||
$record = array_fields($record, $fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($record as &$record_item)
|
||||
{
|
||||
$record_item = array_fields($record_item, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue