本文整理汇总了PHP中Illuminate\Support\Collection::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::get方法的具体用法?PHP Collection::get怎么用?PHP Collection::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send(Collection $data)
{
$validator = $this->validator($data->toArray(), $this->type);
if (!$validator->fails()) {
Mailer::send("emails.{$this->type}", $data->toArray(), function ($message) use($data) {
$fromAddress = $data->get('from_address');
$fromName = $data->get('from_name');
$toAddress = $data->get('to_address');
$toName = $data->get('to_name');
$cc = $data->get('cc[]', []);
$bcc = $data->get('bcc[]', []);
// Send the message
$message->from($fromAddress, $fromName);
$message->to($toAddress, $toName)->subject($data->get('subject'));
foreach ($cc as $address) {
$message->cc($address, null);
}
foreach ($bcc as $address) {
$message->bcc($address, null);
}
});
} else {
// Validation failed
return ['success' => 0, 'status' => "Failed to validate message", 'messages' => $validator->getMessageBag()->all(), 'data' => $data, 'type' => $this->type];
}
if (!count(Mailer::failures())) {
$this->sent_at = Carbon::now();
Log::info("Sent {$this->type} email");
return ['success' => 1, 'status' => "successfully sent message", 'data' => $data, 'type' => $this->type];
}
Log::info("Failed to send {$this->type} email");
return ['success' => 0, 'status' => "failed to send message", 'messages' => "failed to send message", 'data' => $data, 'type' => $this->type];
}
示例2: isAllow
/**
* @param GrantableInterface $grantable
* @param $action
*
* @return mixed
*/
public function isAllow(GrantableInterface $grantable, $action)
{
if (is_null($this->permissions) || $this->permissions->isEmpty()) {
$this->initialize($grantable);
}
return $this->permissions->get($action, false);
}
示例3: loadRules
/**
* @param string $key
*
* @return array
*/
protected function loadRules($key)
{
if (!$this->rules->has($key)) {
$this->rules->put($key, $this->loadRulesFromFile($key));
}
return $this->rules->get($key);
}
示例4: evaluacion
/**
* obtener una evaluacion en específico
* @param int $id
* @return mixed|null
*/
public function evaluacion($id)
{
if ($this->buscarEvaluacion($id) === false) {
return null;
}
return $this->listaEvaluaciones->get($id);
}
示例5: applications
public function applications()
{
$apps = $this->items->get('applications');
if (is_array($apps)) {
$apps = $this->transformToCollections($apps);
}
return new Collection($apps);
}
示例6: moveFile
/**
* @param File $image
* @param string $prefix
* @param String $path
* @return string
*/
public function moveFile(File $image, $path, $prefix = '')
{
$extension = $image->guessExtension();
$code = strtoupper($this->request->get('code'));
$fileName = $code . '-' . $prefix . '.' . $extension;
$image->move(public_path() . $path, $fileName);
return $path . $fileName;
}
示例7: instance
/**
* Get instance of type.
*
* @param string $name
* @param bool $fresh
* @return \GraphQL\Type\Definition\ObjectType
*/
public function instance($name, $fresh = false)
{
if (!$fresh && $this->instances->has($name)) {
return $this->instances->get($name);
}
$type = $this->getType($name)->resolve();
$instance = $type instanceof Model ? (new EloquentType($type, $name))->toType() : $type->toType();
$this->instances->put($name, $instance);
return $instance;
}
示例8: searchIn
/**
* @param string|Model $model
* @param string $query
* @param int|null $perPage
* @param string $pageName
*
* @return LengthAwarePaginator|Collection
* @throws \Exception
*/
public function searchIn($model, $query = "", $perPage = null, $pageName = 'page')
{
if ($model instanceof Model) {
$model = get_class($model);
}
if (!$this->models->offsetExists($model)) {
throw new \Exception("Search engine for model [{$model}] not found");
}
return $this->_search([$this->models->get($model)], $query = "", $perPage = null, $pageName = 'page');
}
示例9: loadProvider
/**
* @param $provider
*
* @return Providers\ProvidersInterface;
* @throws \Exception
*/
private function loadProvider($provider)
{
if (!isset($this->providersAvailable[$provider])) {
throw new \Exception('Lavatar provider ' . $provider . ' does not exist.');
}
$this->providersLoadeds[$provider] = app($this->providersAvailable[$provider]);
$options = $this->config->get($provider, array());
$this->providersLoadeds[$provider]->setupOptions($options);
return $this->providersLoadeds[$provider];
}
示例10: it_should_generate_a_module
public function it_should_generate_a_module(Filesystem $filesystem, Mustache_Engine $mustache, Collection $c)
{
$filesystem->get('template.stub')->shouldBeCalled()->willReturn('template');
$filesystem->put('js/modules/tacos/index.js', 'output')->shouldBeCalled();
$mustache->render('template', ['model_path' => 'modules/tacos/models/taco', 'model' => 'Taco', 'collection_path' => 'modules/tacos/collections/tacos', 'collection' => 'TacoCollection', 'view_path' => 'modules/tacos/views/taco_view', 'view' => 'TacoView'])->shouldBeCalled()->willReturn('output');
$c->get('model')->willReturn(new BackboneComponent('', 'modules/tacos/models/taco', 'Taco'))->shouldBeCalled();
$c->get('view')->willReturn(new BackboneComponent('', 'modules/tacos/views/taco_view', 'TacoView'))->shouldBeCalled();
$c->get('collection')->willReturn(new BackboneComponent('', 'modules/tacos/collections/tacos', 'TacoCollection'))->shouldBeCalled();
$f = new BackboneComponent('js/modules/tacos/index.js', 'index', 'Index');
$this->generate($f, 'template.stub', $c);
}
示例11: process
/**
* Process the payload.
* @param Collection $payload
* @return Collection
*/
public function process($payload)
{
$series = $payload->get('series');
$game = $series->game;
$creator = $payload->get('creator');
$creator->persist();
$creator->relatesToGame($game);
$series->creator()->associate($creator->model);
$creator->model->touch();
return $payload;
}
示例12: item
/**
* Add a new Item (or edit an existing item) to the Group
*
* @param string $name
* @param callable $callback
*
* @return Item
*/
public function item($name, Closure $callback = null)
{
if ($this->items->has($name)) {
$item = $this->items->get($name);
} else {
$item = $this->container->make('Maatwebsite\\Sidebar\\Item');
$item->name($name);
}
$this->call($callback, $item);
$this->addItem($item);
return $item;
}
示例13: instance
/**
* Get instance of connection type.
*
* @param string $name
* @param string|null $parent
* @param bool $fresh
* @return \Nuwave\Lighthouse\Support\Definition\Fields\ConnectionField
*/
public function instance($name, $parent = null, $fresh = false)
{
$instanceName = $this->instanceName($name);
$typeName = $this->typeName($name);
if (!$fresh && $this->instances->has($instanceName)) {
return $this->instances->get($instanceName);
}
$key = $parent ? $parent . '.' . $instanceName : $instanceName;
$nodeType = $this->getSchema()->typeInstance($typeName);
$instance = $this->getInstance($name, $nodeType);
$this->instances->put($key, $instance);
return $instance;
}
示例14: determineHandler
/**
* @return \Spatie\SlashCommand\Handlers\BaseHandler
*
* @throws \Spatie\SlashCommand\Exceptions\RequestCouldNotBeHandled
*/
protected function determineHandler()
{
$handler = collect($this->config->get('handlers'))->map(function (string $handlerClassName) {
if (!class_exists($handlerClassName)) {
throw InvalidHandler::handlerDoesNotExist($handlerClassName);
}
return new $handlerClassName($this->request);
})->filter(function (HandlesSlashCommand $handler) {
return $handler->canHandle($this->request);
})->first();
if (!$handler) {
throw RequestCouldNotBeHandled::noHandlerFound($this->request);
}
return $handler;
}
示例15: parse
/**
* Parse parameters and return the altering classes
*
* @param mixed $parameters
* @return \Illuminate\Support\Collection
*/
public function parse($parameters)
{
// Fetch parameters. If the variable is an array nothing will happen.
// If it's a string, it will be tokenized and will return as an array.
$params = $this->getParameters($parameters);
$collection = new Collection();
foreach ($params as $token => $value) {
// create the manipulator
$manipulator = $this->createManipulator($token);
$className = get_class($manipulator);
// get the classname
if ($collection->has($className)) {
$manipulator = $collection->get($className);
}
// set values
if ($token === self::REQUEST_PARAM_WIDTH) {
$manipulator->setWidth($value);
} elseif ($token === self::REQUEST_PARAM_HEIGHT) {
$manipulator->setHeight($value);
}
// put in the colllection
$collection->put($className, $manipulator);
}
return $collection;
}