-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacros.php
More file actions
executable file
·28 lines (21 loc) · 908 Bytes
/
Copy pathmacros.php
File metadata and controls
executable file
·28 lines (21 loc) · 908 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
<?php
Form::macro('DBSelect', function ($id, $collection, $options = ['id' => 'name']) {
$key = key($options);
$rows = $collection->pluck($options[$key], $key);
return Former::select($id)->options($rows);
});
Form::macro('Config', function ($key, $type = 'text', $default = null) {
if (in_array($type, ['radios', 'radio'])) {
return Former::$type($key)->check(config($key, $default));
}
return Former::$type($key)->value(config($key, $default));
});
HTML::macro('nav_link', function ($route, $text, array $args = []) {
$class = '';
$action = Route::current();
$action = $action->getAction();
if (isset($action['as'])) {
$class = $action['as'] === $route ? ' class="active"' : '';
}
return '<li'.$class.'>'.HTML::linkRoute($route, $text, $args).'</li>';
});