public static function validate($data) { if (is_null($data)) { return $data; } $arr = Arr::only($data, ['updated_at', 'access', 'publish_up', 'publish_down', 'published']); // check empty $fields = ['publish_up' => ['type' => 'datetime', 'value' => 'now()'], 'publish_down' => ['type' => 'datetime', 'value' => null], 'published' => '0']; foreach ($fields as $date_field => $default_value) { $type = null; if (is_array($default_value)) { // get type $type = isset($default_value['type']) ? $default_value['type'] : null; $default_value = isset($default_value['value']) ? $default_value['value'] : null; } if (empty($arr[$date_field])) { $arr[$date_field] = $default_value; } else { // // Test for datetime // // in MySQL, "2016-02-16 05:30 PM" --> "0000-00-00 00:00:00" // PostgreSQL seems okay ;) // if ($type == 'datetime' && ($value = strtotime($arr[$date_field])) !== false) { $arr[$date_field] = date('Y-m-d H:i:s', $value); } } } return $arr; }
/** * Authenticate the user. * * @param array $input * * @return bool */ protected function authenticate($input) { $data = Arr::only($input, ['email', 'password']); $remember = isset($input['remember']) && $input['remember'] === 'yes'; // We should now attempt to login the user using Auth class. If this // failed simply return false. return $this->auth->attempt($data, $remember); }
public function getS3PublicUrl($config, $object_path = '') { $config += ['version' => 'latest']; if ($config['key'] && $config['secret']) { $config['credentials'] = Arr::only($config, ['key', 'secret']); } return (new S3Client($config))->getObjectUrl($config['bucket'], $object_path); }
/** * @param View $view */ public function compose(View $view) { $auth = $this->session->get('auth'); if (empty($auth) || !is_array($auth)) { return; } $view->with(Arr::only($auth, ['host', 'terminal', 'password'])); }
/** * Establish a queue connection. * * @param array $config * @return \Illuminate\Contracts\Queue\Queue */ public function connect(array $config) { $config += ['version' => 'latest']; if ($config['key'] && $config['secret']) { $config['credentials'] = Arr::only($config, ['key', 'secret']); } return new SqsQueue(new SqsClient($config), $config['queue']); }
/** * Get filtered options. * * @param array $options * * @return array */ protected function getFilteredOptions(array $options) { $default = $this->getDefaultOptions(); $options = array_merge($default, $options); $uses = array_unique(array_merge(['path', 'filename', 'extension', 'format'], array_keys($default))); $data = Arr::only($options, $uses); return $data; }
/** * Establish a queue connection. * * @param array $config * @return \Illuminate\Contracts\Queue\Queue */ public function connect(array $config) { $config = array_merge(['version' => 'latest', 'http' => ['connect_timeout' => 60]], $config); if ($config['key'] && $config['secret']) { $config['credentials'] = Arr::only($config, ['key', 'secret']); } return new SqsQueue(new SqsClient($config), $config['queue']); }
/** * Establish a queue connection. * * @param array $config * @return \Illuminate\Contracts\Queue\Queue */ public function connect(array $config) { $config = $this->getDefaultConfiguration($config); if ($config['key'] && $config['secret']) { $config['credentials'] = Arr::only($config, ['key', 'secret']); } return new SqsQueue(new SqsClient($config), $config['queue'], Arr::get($config, 'prefix', '')); }
/** * Create an instance of the Amazon SES Swift Transport driver. * * @return \Swift_SendmailTransport */ protected function createSesDriver() { $config = $this->app['config']->get('services.ses', []); $config += ['version' => 'latest', 'service' => 'email']; if ($config['key'] && $config['secret']) { $config['credentials'] = Arr::only($config, ['key', 'secret']); } return new SesTransport(new SesClient($config)); }
public function store($listener, array $inputs) { $validation = $this->validator->on('create')->with($inputs); if ($validation->fails()) { } $credentials = Arr::only($inputs, ['email', 'password', 'first_name', 'last_name']); $account = $this->account->createNewAccount($credentials); $profile = $this->profile->createUserProfile($account, Arr::except($inputs, $credentials)); $this->fireEvent(self::MODULENAME, 'created', [$account]); }
/** * @param $key * @param $secret * @param $region * * @return \Illuminate\Mail\Transport\SesTransport * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException */ public static function getTransport($key, $secret, $region) { if (empty($key) || empty($secret) || empty($region)) { throw new InternalServerErrorException('Missing one or more configuration for SES service.'); } $config = ['key' => $key, 'secret' => $secret, 'region' => $region, 'version' => 'latest', 'service' => 'email']; if ($config['key'] && $config['secret']) { $config['credentials'] = Arr::only($config, ['key', 'secret']); } return new SesTransport(new SesClient($config)); }
static function getMethods($model) { $ret = []; $refl = new \ReflectionClass($model); foreach ($refl->getMethods() as $method) { $ret[$method->getName()]['method'] = $method; $relf_text = file($method->getFileName()); $source = Arr::only($relf_text, range($method->getStartLine() - 1, $method->getEndLine() - 1)); $source = array_map('trim', $source); $ret[$method->getName()]['source'] = implode('', $source); $ret[$method->getName()]['start'] = $method->getStartLine(); $ret[$method->getName()]['end'] = $method->getEndLine(); } return $ret; }
/** * 承诺用户所期望的点歌要求 * * @param $request * @param $wish * * @return string * @internal param $ \Illuminate\Http\Request $request* \Illuminate\Http\Request $request * @internal param $ array* $wish */ private function promiseUserWish($request, $wish) { // 根据referer拿到当前歌曲的ID, 匹配的数字放入到数组下标为1的项 preg_match('/\\/(\\d+)$/', $request->header('Referer'), $song); if (empty($song)) { /** 此处接收的是JSON格式 */ $msg = \Illuminate\Support\Arr::only($request->json()->all(), ['receiver', 'message']); /* 保存新的点歌信息 */ $song = \App\Song::storeNewSong($request->json('songName'), $request->json('singerName')); } else { if (is_numeric($song[1])) { /** 此处接收的是FORM-DATA */ $msg = $request->only(['receiver', 'message']); $song = intval($song[1]); } else { /* 既不为空,也找不到对应歌曲ID就直接报错 */ abort(405); } } return $this->writeUserWish($wish, $song, $msg); }
/** * Create a Flysystem instance with the given adapter. * * @param \League\Flysystem\AdapterInterface $adapter * @param array $config * @return \Leage\Flysystem\FlysystemInterface */ protected function createFlysystem(AdapterInterface $adapter, array $config) { $config = Arr::only($config, ['visibility']); return new Flysystem($adapter, count($config) > 0 ? $config : null); }
/** * @param array $values * @return AttributeMapper */ public function only(array $values) : AttributeMapper { $this->attributes = Arr::only($this->attributes, $values); return $this; }
/** * Get the login key. * * @param array $input * * @return string */ protected function getLoginKey(array $input) { return implode('', Arr::only($input, ['email', '_ip'])); }
/** * Format the given S3 configuration with the default options. * * @param array $config * @return array */ protected function formatS3Config(array $config) { $config += ['version' => 'latest']; if ($config['key'] && $config['secret']) { $config['credentials'] = Arr::only($config, ['key', 'secret']); } return $config; }
/** * Get the DSN string for a DbLib connection. * * @param array $config * * @return string */ protected static function getDblibDsn(array $config) { $arguments = ['host' => static::buildHostString($config, ':'), 'dbname' => $config['database']]; $arguments = array_merge($arguments, Arr::only($config, ['appname', 'charset'])); return static::buildConnectString('dblib', $arguments); }
/** * Apply any tag filters added to this query. * Will return false if any requested tag does not exist. * * @return bool */ protected function applyTagFilters() { if (isset($this->tag_filters_applied)) { return $this->tag_filters_applied; } if (empty($this->filters)) { return $this->tag_filters_applied = false; } $tag_model = $this->model->tagModel(); $tag_instance = new $tag_model(); $tag_query = $tag_instance->newQuery(); if (isset($this->tag_context)) { if (method_exists($tag_model, 'applyQueryContext')) { call_user_func_array(array($tag_model, 'applyQueryContext'), array($tag_query, $this->tag_context)); } } $filters = $this->filters; $tag_query->where(function ($query) use($filters) { foreach ($filters as $filter) { if (isset($filter['tag_id'])) { if (is_array($filter['tag_id'])) { $query->orWhereIn('id', $filter['tag_id']); } else { $query->orWhere('id', $filter['tag_id']); } } else { if (isset($filter['tag'])) { if (is_array($filter['tag'])) { $query->orWhereIn('name', $filter['tag']); } else { $query->orWhere('name', $filter['tag']); } } } } }); $tags = $tag_query->get(); $tag_items = $tags->lists('num_items', 'id'); $found = array('tag' => $tags->lists('id', 'name'), 'tag_id' => $tags->lists('id', 'id')); foreach ($filters as &$filter) { $type = current(array_keys($filter)); $value = current($filter); if (is_array($value)) { $intersect = array_intersect(array_values($value), array_keys($found[$type])); if (empty($intersect)) { return $this->tag_filters_applied = false; } $filter['id'] = Arr::only($found[$type], $intersect); $filter['num_items'] = 100000000 + max(Arr::only($tag_items, $filter['id'])); } else { if (!array_key_exists($value, $found[$type])) { return $this->tag_filters_applied = false; } $filter['id'] = $found[$type][$value]; $filter['num_items'] = $tag_items[$filter['id']]; } } usort($filters, function ($a, $b) { return $a['num_items'] < $b['num_items'] ? -1 : 1; }); $set_distinct = false; $first_filter = current(array_splice($filters, 0, 1)); if (is_array($first_filter['id'])) { $this->whereIn('t.tag_id', $first_filter['id']); if (!$set_distinct) { $this->distinct(); $set_distinct = true; } } else { $this->where('t.tag_id', $first_filter['id']); } foreach ($filters as $i => $f) { $this->join("{$this->model->taggableTable()} AS t{$i}", function ($join) use($i, $f) { $join_query = $join->on('t.xref_id', '=', "t{$i}.xref_id"); if (!is_array($f['id'])) { $join_query->where("t{$i}.tag_id", '=', $f['id']); } }); if (is_array($f['id'])) { $this->whereIn("t{$i}.tag_id", $f['id']); if (!$set_distinct) { $this->distinct(); $set_distinct = true; } } } return $this->tag_filters_applied = true; }
/** * Get the items with the specified keys. * * @param mixed $keys * @return static */ public function only($keys) { return new static(Arr::only($this->items, $keys)); }
/** * Get the items with the specified keys. * * @param mixed $keys * @return static */ public function only($keys) { $keys = is_array($keys) ? $keys : func_get_args(); return new static(Arr::only($this->items, $keys)); }
/** * Build a single cluster seed string from array. * * @param array $server * @return string */ protected function buildClusterConnectionString(array $server) { return $server['host'] . ':' . $server['port'] . '?' . http_build_query(Arr::only($server, ['database', 'password', 'prefix', 'read_timeout'])); }
/** * Create a Flysystem instance with the given adapter. * * @param \League\Flysystem\AdapterInterface $adapter * @param array $config * @return \League\Flysystem\FlysystemInterface */ protected function createFlysystem(AdapterInterface $adapter, array $config) { if (class_exists('League\\Flysystem\\EventableFilesystem\\EventableFilesystem')) { $fsClass = \League\Flysystem\EventableFilesystem\EventableFilesystem::class; } else { $fsClass = \League\Flysystem\Filesystem::class; } if (class_exists('League\\Flysystem\\Cached\\CachedAdapter')) { $adapter = $this->decorateWithCachedAdapter($adapter, Arr::get($config, 'cache', [])); } $config = Arr::only($config, ['visibility']); return new $fsClass($adapter, count($config) > 0 ? $config : null); }
/** * Retrieve an array item from the cache by key. * * @param array $keys * @return array */ public function getMany(array $keys) { return array_merge(array_fill_keys($keys, null), Arr::only($this->storage, $this->prefixKeys($keys))); }
/** * Returns only the models from the collection with the specified keys. * * @param mixed $keys * @return static */ public function only($keys) { $dictionary = Arr::only($this->getDictionary(), $keys); return new static(array_values($dictionary)); }
/** * Create an instance of the Amazon S3 driver. * * @param array $config * @return \Illuminate\Contracts\Filesystem\Cloud */ public function createS3Driver(array $config) { $config += ['version' => 'latest']; if ($config['key'] && $config['secret']) { $config['credentials'] = Arr::only($config, ['key', 'secret']); } return $this->adapt(new Flysystem(new S3Adapter(new S3Client($config), $config['bucket']))); }
/** * Returns only the models from the collection with the specified keys. * * @param mixed $keys * @return static */ public function only($keys) { if (is_null($keys)) { return new static($this->items); } $dictionary = Arr::only($this->getDictionary(), $keys); return new static(array_values($dictionary)); }
/** * Returns only the models from the collection with the specified keys. * * @param mixed $keys * @return static */ public function only($keys) { $keys = is_array($keys) ? $keys : func_get_args(); $dictionary = Arr::only($this->getDictionary(), $keys); return new static(array_values($dictionary)); }
/** * Get a subset of the items from the given array. * * @param array $array * @param array|string $keys * @return array */ function array_only($array, $keys) { return Arr::only($array, $keys); }
/** * {@inheritdoc} */ public function __construct($app) { parent::__construct($app); if (class_exists('\\Zhuxiaoqiao\\Flysystem\\BaiduBos\\BaiduBosAdapter')) { $this->extend('bos', function ($app, $config) { return $this->createFlysystem(new \Zhuxiaoqiao\Flysystem\BaiduBos\BaiduBosAdapter(new \BaiduBce\Services\Bos\BosClient(Arr::except($config, ['driver', 'bucket'])), $config['bucket']), $config); }); } if (class_exists('\\Enl\\Flysystem\\Cloudinary\\CloudinaryAdapter')) { $this->extend('cloudinary', function ($app, $config) { return $this->createFlysystem(new \Enl\Flysystem\Cloudinary\CloudinaryAdapter(new \Enl\Flysystem\Cloudinary\ApiFacade($config)), $config); }); } elseif (class_exists('\\T3chnik\\FlysystemCloudinaryAdapter\\CloudinaryAdapter')) { $this->extend('cloudinary', function ($app, $config) { return $this->createFlysystem(new \T3chnik\FlysystemCloudinaryAdapter\CloudinaryAdapter($config, new \Cloudinary\Api()), $config); }); } if (class_exists('\\Rokde\\Flysystem\\Adapter\\LocalDatabaseAdapter')) { $this->extend('eloquent', function ($app, $config) { return $this->createFlysystem(new \Rokde\Flysystem\Adapter\LocalDatabaseAdapter($app->make(Arr::get($config, 'model', '\\Rokde\\Flysystem\\Adapter\\Model\\FileModel'))), $config); }); } if (class_exists('\\Litipk\\Flysystem\\Fallback\\FallbackAdapter')) { $this->extend('fallback', function ($app, $config) { return $this->createFlysystem(new \Litipk\Flysystem\Fallback\FallbackAdapter($this->disk($config['main'])->getAdapter(), $this->disk($config['fallback'])->getAdapter()), $config); }); } if (class_exists('\\Potherca\\Flysystem\\Github\\GithubAdapter')) { $this->extend('github', function ($app, $config) { $settings = new \Potherca\Flysystem\Github\Settings($config['project'], [\Potherca\Flysystem\Github\Settings::AUTHENTICATE_USING_TOKEN, $config['token']]); return $this->createFlysystem(new \Potherca\Flysystem\Github\GithubAdapter(new \Potherca\Flysystem\Github\Api(new \Github\Client(), $settings)), $config); }); } if (class_exists('\\Ignited\\Flysystem\\GoogleDrive\\GoogleDriveAdapter')) { $this->extend('gdrive', function ($app, $config) { $client = new \Google_Client(); $client->setClientId($config['client_id']); $client->setClientSecret($config['secret']); $client->setAccessToken(json_encode(["access_token" => $config['token'], "expires_in" => 3920, "token_type" => "Bearer", "created" => time()])); return $this->createFlysystem(new \Ignited\Flysystem\GoogleDrive\GoogleDriveAdapter(new \Google_Service_Drive($client)), $config); }); } if (class_exists('\\Superbalist\\Flysystem\\GoogleStorage\\GoogleStorageAdapter')) { $this->extend('google', function ($app, $config) { $client = new \Google_Client(); $client->setAssertionCredentials(new \Google_Auth_AssertionCredentials($config['account'], [\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL], file_get_contents($config['p12_file']), $config['secret'])); $client->setDeveloperKey($config['developer_key']); return $this->createFlysystem(new \Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter(new \Google_Service_Storage($client), $config['bucket']), $config); }); } if (class_exists('\\Litipk\\Flysystem\\Fallback\\FallbackAdapter') && class_exists('\\League\\Flysystem\\Replicate\\ReplicateAdapter')) { $this->extend('mirror', function ($app, $config) { return $this->createFlysystem($this->buildMirrors($config['disks']), $config); }); } if (class_exists('\\JacekBarecki\\FlysystemOneDrive\\Adapter\\OneDriveAdapter')) { $this->extend('onedrive', function ($app, $config) { return $this->createFlysystem(new \JacekBarecki\FlysystemOneDrive\Adapter\OneDriveAdapter(new \JacekBarecki\FlysystemOneDrive\Client\OneDriveClient(Arr::get($config, 'access_token'), new \GuzzleHttp\Client())), $config); }); } elseif (class_exists('\\Ignited\\Flysystem\\OneDrive\\OneDriveAdapter')) { $this->extend('onedrive', function ($app, $config) { $oneConfig = Arr::only($config, ['base_url', 'access_token']); if ($config['use_logger']) { $logger = Log::getMonolog(); } else { $logger = null; } return $this->createFlysystem(new \Ignited\Flysystem\OneDrive\OneDriveAdapter(\Ignited\Flysystem\OneDrive\OneDriveClient::factory($oneConfig, $logger)), $config); }); } if (class_exists('\\Orzcc\\AliyunOss\\AliyunOssAdapter')) { $this->extend('oss', function ($app, $config) { $ossconfig = ['AccessKeyId' => $config['access_id'], 'AccessKeySecret' => $config['access_key']]; if (isset($config['endpoint']) && !empty($config['endpoint'])) { $ossconfig['Endpoint'] = $config['endpoint']; } return $this->createFlysystem(new \Orzcc\AliyunOss\AliyunOssAdapter(\Aliyun\OSS\OSSClient::factory($ossconfig), $config['bucket'], $config['prefix']), $config); }); } elseif (class_exists('\\Shion\\Aliyun\\OSS\\Adapter\\OSSAdapter')) { $this->extend('oss', function ($app, $config) { return $this->createFlysystem(new \Shion\Aliyun\OSS\Adapter\OSSAdapter(new \Shion\Aliyun\OSS\Client\OSSClient(Arr::except($config, ['driver', 'bucket'])), $config['bucket']), $config); }); } if (class_exists('\\EQingdan\\Flysystem\\Qiniu\\QiniuAdapter')) { $this->extend('qiniu', function ($app, $config) { return $this->createFlysystem(new \EQingdan\Flysystem\Qiniu\QiniuAdapter($config['accessKey'], $config['secretKey'], $config['bucket'], $config['domain']), $config); }); } elseif (class_exists('\\Polev\\Flysystem\\Qiniu\\QiniuAdapter')) { $this->extend('qiniu', function ($app, $config) { return $this->createFlysystem(new \Polev\Flysystem\Qiniu\QiniuAdapter($config['accessKey'], $config['secretKey'], $config['bucket']), $config); }); } if (class_exists('\\Danhunsaker\\Flysystem\\Redis\\RedisAdapter')) { $this->extend('redis', function ($app, $config) { $client = $app->make('redis')->connection(Arr::get($config, 'connection', 'default')); return $this->createFlysystem(new \Danhunsaker\Flysystem\Redis\RedisAdapter($client), $config); }); } if (class_exists('\\Engineor\\Flysystem\\RunaboveAdapter')) { $this->extend('runabove', function ($app, $config) { $config['region'] = constant(\Engineor\Flysystem\Runabove::class . '::REGION_' . strtoupper($config['region'])); $client = new \Engineor\Flysystem\Runabove(Arr::except($config, ['driver'])); return $this->createFlysystem(new \Engineor\Flysystem\RunaboveAdapter($client->getContainer()), $config); }); } if (class_exists('\\Coldwind\\Filesystem\\KvdbAdapter')) { $this->extend('sae', function ($app, $config) { return $this->createFlysystem(new \Coldwind\Filesystem\KvdbAdapter(new \Coldwind\Filesystem\KvdbClient()), $config); }); } if (class_exists('\\RobGridley\\Flysystem\\Smb\\SmbAdapter')) { $this->extend('smb', function ($app, $config) { $server = new \Icewind\SMB\Server($config['host'], $config['username'], $config['password']); $share = $server->getShare($config['path']); return $this->createFlysystem(new \RobGridley\Flysystem\Smb\SmbAdapter($share), $config); }); } if (class_exists('\\Emgag\\Flysystem\\TempdirAdapter')) { $this->extend('temp', function ($app, $config) { return $this->createFlysystem(new \Emgag\Flysystem\TempdirAdapter(Arr::get($config, 'prefix'), Arr::get($config, 'tempdir')), $config); }); } }