Skip to content
Permalink
Browse files

formatting

  • Loading branch information
taylorotwell committed Jan 23, 2020
1 parent b54799c commit 104c539c342d395e2f3c4ba7339df095f83f6352
@@ -141,7 +141,7 @@ public function parameter($previous, $new)
}

/**
* Set a middleware to the resource.
* Add middleware to the resource routes.
*
* @param mixed $middleware
* @return \Illuminate\Routing\PendingResourceRegistration
@@ -154,7 +154,7 @@ public function middleware($middleware)
}

/**
* Set the shallow option for a resource.
* Indicate that the resource routes should have "shallow" nesting.
*
* @param bool $shallow
* @return \Illuminate\Routing\PendingResourceRegistration
@@ -230,7 +230,7 @@ protected function addResourceStore($name, $base, $controller, $options)
*/
protected function addResourceShow($name, $base, $controller, $options)
{
$name = $this->getNameWithShallowness($name, $options);
$name = $this->getShallowName($name, $options);

$uri = $this->getResourceUri($name).'/{'.$base.'}';

@@ -250,7 +250,7 @@ protected function addResourceShow($name, $base, $controller, $options)
*/
protected function addResourceEdit($name, $base, $controller, $options)
{
$name = $this->getNameWithShallowness($name, $options);
$name = $this->getShallowName($name, $options);

$uri = $this->getResourceUri($name).'/{'.$base.'}/'.static::$verbs['edit'];

@@ -270,7 +270,7 @@ protected function addResourceEdit($name, $base, $controller, $options)
*/
protected function addResourceUpdate($name, $base, $controller, $options)
{
$name = $this->getNameWithShallowness($name, $options);
$name = $this->getShallowName($name, $options);

$uri = $this->getResourceUri($name).'/{'.$base.'}';

@@ -290,7 +290,7 @@ protected function addResourceUpdate($name, $base, $controller, $options)
*/
protected function addResourceDestroy($name, $base, $controller, $options)
{
$name = $this->getNameWithShallowness($name, $options);
$name = $this->getShallowName($name, $options);

$uri = $this->getResourceUri($name).'/{'.$base.'}';

@@ -299,6 +299,20 @@ protected function addResourceDestroy($name, $base, $controller, $options)
return $this->router->delete($uri, $action);
}

/**
* Get the name for a given resource with shallowness applied when applicable.
*
* @param string $name
* @param array $options
* @return string
*/
protected function getShallowName($name, $options)
{
return isset($options['shallow']) && $options['shallow']
? last(explode('.', $name))
: $name;
}

/**
* Get the base resource URI for a given resource.
*
@@ -409,22 +423,6 @@ protected function getResourceRouteName($resource, $method, $options)
return trim(sprintf('%s%s.%s', $prefix, $name, $method), '.');
}

/**
* Get the name for a given resource with shallowness applied when needed.
*
* @param string $name
* @param array $options
* @return string
*/
protected function getNameWithShallowness($name, $options)
{
if (isset($options['shallow']) && $options['shallow']) {
return last(explode('.', $name));
} else {
return $name;
}
}

/**
* Set or unset the unmapped global parameters to singular.
*

0 comments on commit 104c539

Please sign in to comment.
You can’t perform that action at this time.