Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Support multiple values in some has() methods #18758

Merged
merged 2 commits into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Illuminate/Auth/Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ public function __construct(Container $container, callable $userResolver, array
/**
* Determine if a given ability has been defined.
*
* @param string $ability
* @param string|array $ability
* @return bool
*/
public function has($ability)
{
return isset($this->abilities[$ability]);
$abilities = is_array($ability) ? $ability : func_get_args();

foreach ($abilities as $ability) {
if (! isset($this->abilities[$ability])) {
return false;
}
}

return true;
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,15 @@ public function current()
*/
public function has($name)
{
return $this->routes->hasNamedRoute($name);
$names = is_array($name) ? $name : func_get_args();

foreach ($names as $value) {
if (! $this->routes->hasNamedRoute($value)) {
return false;
}
}

return true;
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,15 @@ public function keyBy($keyBy)
*/
public function has($key)
{
return $this->offsetExists($key);
$keys = is_array($key) ? $key : func_get_args();

foreach ($keys as $value) {
if (! $this->offsetExists($value)) {
return false;
}
}

return true;
}

/**
Expand Down