本文整理汇总了PHP中Illuminate\Support\Collection::keys方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::keys方法的具体用法?PHP Collection::keys怎么用?PHP Collection::keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::keys方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStoredUrls
/**
* @param bool $asArray
* @return array|static
**/
public function getStoredUrls($asArray = false)
{
$keys = $this->lookups->keys();
if ($asArray) {
return $keys->toArray();
} else {
return $keys;
}
}
示例2: whatWouldYouLikeToRegister
/**
* Ask the user what they would like to register with the application
*
* @return void
*/
public function whatWouldYouLikeToRegister()
{
$choices = $this->registrars->keys();
$choices[] = 'No more';
$registerType = $this->askWithCompletion('What would you like to register? (' . implode(', ', $choices->toArray()) . ')', $choices->toArray(), $choices->first());
if ($registerType === 'No more') {
foreach ($this->registrars as $registrar) {
$registrar->afterRegistration();
}
$this->updateEnvFile();
return;
}
if ($registerType == '' || !$this->registrars->has($registerType)) {
$this->error('Unable to register that. Please try again.');
$this->whatWouldYouLikeToRegister();
return;
}
$this->registrars->get($registerType)->register();
$this->whatWouldYouLikeToRegister();
}
示例3: handle
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
// New permissions
$permissions = new Collection();
// Remove not existing permissions
Permission::whereNotIn('resource', $this->routes->keys()->toArray())->delete();
foreach ($this->routes as $route) {
// Do we have the current permission in the database. If so skip it...
$existing_permission = Permission::where('resource', '=', $route['resource'])->first();
if ($existing_permission) {
continue;
}
// Skip some methods
$data = $this->getPermissionData($route);
if ($data['method'] == 'missingMethod') {
continue;
}
// Add new permission
$permissions->push(Permission::create($data));
}
$this->assignPermissions($permissions);
}
示例4: serialize
public static function serialize(Collection &$cards, $attr = false)
{
$ary = [];
foreach ($cards->keys() as $key) {
$ary[$key] = $cards->get($key)->map(function ($item, $key) use($attr) {
switch ($attr) {
case true:
return $item->toJSON();
case false:
return $item->getAttribute($item->getKeyName());
default:
//TODO: Complete attribute selection
$attributes = collect($item->getAttributes());
return 'TODO';
}
})->toArray();
}
$cards = json_encode($ary);
}
示例5: testKeys
public function testKeys()
{
$c = new Collection(['name' => 'taylor', 'framework' => 'laravel']);
$this->assertEquals(['name', 'framework'], $c->keys()->all());
}
示例6: newQueryWithoutTenants
/**
* Get a new Eloquent Builder instance without any of the tenant scopes applied.
*
* @param Model $model
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function newQueryWithoutTenants(Model $model)
{
return $model->newQuery()->withoutGlobalScopes($this->tenants->keys()->toArray());
}
示例7: runCommandsWithParameters
/**
* Runs the given commands and paases them all the given parameters.
*
* @param Collection $commands
* @param array $parameters
*
* @return void
*/
private function runCommandsWithParameters(Collection $commands, array $parameters)
{
$commands->keys()->each(function ($command) use($parameters) {
$this->call($command, $parameters);
});
}
示例8: getKeys
/**
* @return array
*/
public function getKeys()
{
return $this->fields->keys()->all();
}