本文整理汇总了PHP中Illuminate\Support\Arr::only方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::only方法的具体用法?PHP Arr::only怎么用?PHP Arr::only使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Arr
的用法示例。
在下文中一共展示了Arr::only方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
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;
}
示例2: authenticate
/**
* 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);
}
示例3: getS3PublicUrl
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);
}
示例4: compose
/**
* @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']));
}
示例5: connect
/**
* 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']);
}
示例6: getFilteredOptions
/**
* 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;
}
示例7: connect
/**
* 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']);
}
示例8: connect
/**
* 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', ''));
}
示例9: createSesDriver
/**
* 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));
}
示例10: store
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]);
}
示例11: getTransport
/**
* @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));
}
示例12: getMethods
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;
}
示例13: promiseUserWish
/**
* 承诺用户所期望的点歌要求
*
* @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);
}
示例14: createFlysystem
/**
* 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);
}
示例15: only
/**
* @param array $values
* @return AttributeMapper
*/
public function only(array $values) : AttributeMapper
{
$this->attributes = Arr::only($this->attributes, $values);
return $this;
}