forked from overdatum/admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.php
More file actions
39 lines (33 loc) · 744 Bytes
/
helpers.php
File metadata and controls
39 lines (33 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
function model_array_pluck($models, $value, $key = null)
{
$result = array();
if( ! is_array($models)) return $result;
$i = 0;
foreach ($models as $model)
{
$result[is_null($key) ? $model->get_key() : ($key instanceof Closure ? $key($model) : ($key == '' ? $i : $model->$key))] = $value instanceof Closure ? $value($model) : $model->$value;
$i++;
}
return $result;
}
function prefix($for)
{
return Config::get('layla.'.$for.'.url_prefix').'/';
}
function merge_attributes($array1, $array2)
{
$array = $array1;
foreach ($array2 as $key => $value)
{
if(array_key_exists($key, $array1))
{
$array[$key] = $array1[$key] .= ' '.$array2[$key];
}
else
{
$array[$key] = $array2[$key];
}
}
return $array;
}