mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-10 19:51:07 +03:30
29 lines
737 B
PHP
29 lines
737 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
if (!function_exists('pluckValues')) {
|
|
/**
|
|
* Extracts the values of a given key from an array of associative arrays.
|
|
*
|
|
* @param array $array The input array of associative arrays.
|
|
* @param string $key The key whose values need to be extracted.
|
|
* @return array An array containing the values of the specified key.
|
|
*/
|
|
function pluckValues(array $array, string $key): array
|
|
{
|
|
return array_map(function ($item) use ($key) {
|
|
return $item[$key] ?? null;
|
|
}, $array);
|
|
}
|
|
}
|
|
|
|
if (!function_exists('getNamespaceMap')) {
|
|
|
|
function getNamespaceMap(Model $model): string
|
|
{
|
|
return $model->getMorphClass();
|
|
}
|
|
|
|
}
|