Skip to content

Commit

Permalink
improve path & name convention
Browse files Browse the repository at this point in the history
  • Loading branch information
joesama committed Oct 29, 2019
1 parent 1f24294 commit 2a988b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Routings/Concerns/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ public function pathConvention(string $type, string $function, array $attributes
if (!\is_array($keymap) || empty($keymap)) {
return $function;
} else {
$keymap = collect($keymap)->map(function ($id) {
$keymap = collect($keymap)->map(function ($id, $key) use ($type) {
if (!is_int($key) && strtolower($key) === strtolower($type)) {
return null;
}

return '{' . $id . '}';
})->implode('/');

Expand Down Expand Up @@ -107,6 +111,6 @@ public function namedConvention(string $type, string $controller, string $functi

$names = array_change_key_case($named, \CASE_LOWER);

return Str::lower(collect($names)->get($type));
return Str::lower(collect($names)->get($type)) ?? Str::lower($type . '.' . $controller . '.' . $function);
}
}

0 comments on commit 2a988b1

Please sign in to comment.