/** * Retrieve a user by the given credentials. * * @param array $credentials * @return Authenticatable|null */ public function retrieveByCredentials(array $credentials) { $query = $this->model->newQuery(); foreach (Arr::except($credentials, 'password') as $key => $value) { $query->where($key, $value); } return $query->first(); }
/** * Authenticate the user. * * @param array $input * * @return bool */ protected function authenticate(array $input) { $remember = isset($input['remember']) && $input['remember'] === 'yes'; $data = Arr::except($input, ['remember']); // We should now attempt to login the user using Auth class. If this // failed simply return false. return $this->auth->attempt($data, $remember); }
/** * Config the laravel auth package (override). */ private function configLaravelAuthPackage() { /** @var \Illuminate\Contracts\Config\Repository $config */ $config = $this->config(); $config->set('laravel-auth', Arr::except($config->get('arcanesoft.auth'), ['route', 'hasher'])); if (SocialAuthenticator::isEnabled()) { $this->app->register(\Laravel\Socialite\SocialiteServiceProvider::class); } }
protected function saveModel(Eloquent $model, array $data) { $data = Arr::except($data, ['_token']); foreach ($data as $key => $value) { $model->setAttribute($key, $value); } $model->save(); return $model; }
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]); }
/** * Detect all extensions. * * @return \Illuminate\Support\Collection|array */ public function detect() { $this->events->fire('orchestra.extension: detecting'); $extensions = $this->finder()->detect(); $collection = $extensions->map(function ($item) { return Arr::except($item, ['description', 'author', 'url', 'version']); }); $this->memory->put('extensions.available', $collection->all()); return $extensions; }
/** * subscribe. * * @method subscribe */ public function subscribe() { $this->laravel['events']->listen('composing:*', function ($view) { $name = $view->getName(); $data = $this->limitCollection(Arr::except($view->getData(), ['__env', 'app'])); $path = self::editorLink($view->getPath()); preg_match('/href=\\"(.+)\\"/', $path, $m); $path = count($m) > 1 ? '(<a href="' . $m[1] . '">source</a>)' : ''; $this->views[] = compact('name', 'data', 'path'); }); }
/** * Deactivate an extension. * * @param string $name * * @return bool */ public function deactivate($name) { $memory = $this->memory; $active = $memory->get('extensions.active', []); if (!isset($active[$name])) { return false; } $memory->put('extensions.active', Arr::except($active, $name)); $this->dispatcher->deactivating($name, $active[$name]); return true; }
function toCard() { $ret = $this->toArray(); unset($ret['id']); unset($ret['created_at']); unset($ret['updated_at']); unset($ret['deleted_at']); unset($ret['js_filter']); unset($ret['js_sort']); unset($ret['order']); return Arr::except($ret, $this->getHidden()); }
/** * {@inheritdoc} */ public function render() { $grid = $this->grid; // Add paginate value for current listing while appending query string, // however we also need to remove ?page from being added twice. $input = Arr::except($this->request->query(), [$grid->pageName]); $rows = $grid->rows(); $pagination = true === $grid->paginated() ? $grid->model->appends($input) : ''; $data = ['attributes' => ['row' => $grid->rows->attributes, 'table' => $grid->attributes], 'columns' => $grid->columns(), 'empty' => $this->translator->get($grid->empty), 'grid' => $grid, 'pagination' => $pagination, 'rows' => $rows]; // Build the view and render it. return $this->view->make($grid->view)->with($data)->render(); }
/** * Bootstrap any application services. * * @return void */ public function boot() { // replace HTTP_HOST with site url setted in options to prevent CDN source problems if (!option('auto_detect_asset_url')) { $rootUrl = option('site_url'); if ($this->app['url']->isValidUrl($rootUrl)) { $this->app['url']->forceRootUrl($rootUrl); } } if (option('force_ssl')) { $this->app['url']->forceSchema('https'); } Event::listen(Events\RenderingHeader::class, function ($event) { // provide some application information for javascript $blessing = array_merge(Arr::except(config('app'), ['key', 'providers', 'aliases', 'cipher', 'log', 'url']), ['baseUrl' => url('/')]); $event->addContent('<script>var blessing = ' . json_encode($blessing) . ';</script>'); }); }
/** * Open up a new HTML form. * * @param array $options * * @return \Illuminate\Support\HtmlString */ public function open(array $options = []) { $method = Arr::get($options, 'method', 'post'); // We need to extract the proper method from the attributes. If the method is // something other than GET or POST we'll use POST since we will spoof the // actual method since forms don't support the reserved methods in HTML. $attributes = ['method' => $this->getMethod($method), 'action' => $this->getAction($options), 'accept-charset' => 'UTF-8']; // If the method is PUT, PATCH or DELETE we will need to add a spoofer hidden // field that will instruct the Symfony request to pretend the method is a // different method than it actually is, for convenience from the forms. $append = $this->getAppendage($method); if (isset($options['files']) && $options['files']) { $options['enctype'] = 'multipart/form-data'; } // Finally we're ready to create the final form HTML field. We will attribute // format the array of attributes. We will also add on the appendage which // is used to spoof requests for this PUT, PATCH, etc. methods on forms. $attributes = array_merge($attributes, Arr::except($options, $this->reserved)); // Finally, we will concatenate all of the attributes into a single string so // we can build out the final form open statement. We'll also append on an // extra value for the hidden _method field if it's needed for the form. $attributes = $this->getHtmlBuilder()->attributes($attributes); return $this->toHtmlString('<form' . $attributes . '>' . $append); }
/** * Get the user for the given credentials. * * @param array $credentials * @return \Illuminate\Contracts\Auth\CanResetPassword * * @throws \UnexpectedValueException */ public function getUser(array $credentials) { $credentials = Arr::except($credentials, ['token']); $user = $this->users->retrieveByCredentials($credentials); if ($user && !$user instanceof CanResetPasswordContract) { throw new UnexpectedValueException('User must implement CanResetPassword interface.'); } return $user; }
protected function getTables() { $this->info('Начало получение таблиц'); // $connection = \DB::connection($this->connection_name); $dbname = \DB::connection($this->connection_name)->getDatabaseName(); $sql = 'select TABLE_NAME AS t from information_schema.tables where table_schema=\'' . $dbname . '\''; $tables = []; $select = \DB::connection($this->connection_name)->select($sql, [], false); foreach ($select as $k) { $k = (string) $k->t; $tables[$k] = $k; } $tables = Arr::except($tables, $this->ignore_tables); $this->tables = $tables; }
/** * Parse the failed job row. * * @param array $failed * @return array */ protected function parseFailedJob(array $failed) { $row = array_values(Arr::except($failed, ['payload'])); array_splice($row, 3, 0, $this->extractJobName($failed['payload'])); return $row; }
/** * Prepare the bindings for an update statement. * * @param array $bindings * @param array $values * @return array */ public function prepareBindingsForUpdate(array $bindings, array $values) { $bindingsWithoutJoin = Arr::except($bindings, 'join'); return array_values(array_merge($values, $bindings['join'], Arr::flatten($bindingsWithoutJoin))); }
/** * Clone the model into a new, non-existing instance. * * @param array|null $except * @return \Illuminate\Database\Eloquent\Model */ public function replicate(array $except = null) { $defaults = [$this->getKeyName(), $this->getCreatedAtColumn(), $this->getUpdatedAtColumn()]; $except = $except ? array_unique(array_merge($except, $defaults)) : $defaults; $attributes = Arr::except($this->attributes, $except); $instance = new static(); $instance->setRawAttributes($attributes); return $instance->setRelations($this->relations); }
public function getOptions() { $this->getKernel()->call('--ansi'); $defaults = ['username' => 'LARAVEL', 'hostname' => php_uname('n'), 'os' => PHP_OS, 'helpInfo' => $this->getKernel()->output()]; return array_merge($defaults, Arr::except($this->config, ['enabled', 'whitelists', 'route', 'commands'])); }
/** * Get all items except for those with the specified keys. * * @param mixed $keys * @return static */ public function except($keys) { $keys = is_array($keys) ? $keys : func_get_args(); return new static(Arr::except($this->items, $keys)); }
/** * Returns all models in the collection except the models with specified keys. * * @param mixed $keys * @return static */ public function except($keys) { $dictionary = Arr::except($this->getDictionary(), $keys); return new static(array_values($dictionary)); }
/** * Merge the given group attributes. * * @param array $new * @param array $old * @return array */ public static function mergeGroup($new, $old) { $new['namespace'] = static::formatUsesPrefix($new, $old); $new['prefix'] = static::formatGroupPrefix($new, $old); if (isset($new['domain'])) { unset($old['domain']); } $new['where'] = array_merge(isset($old['where']) ? $old['where'] : [], isset($new['where']) ? $new['where'] : []); if (isset($old['as'])) { $new['as'] = $old['as'] . (isset($new['as']) ? $new['as'] : ''); } return array_merge_recursive(Arr::except($old, ['namespace', 'prefix', 'where', 'as']), $new); }
/** * {@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); }); } }
/** * Returns all models in the collection except the models with specified keys. * * @param mixed $keys * @return static */ public function except($keys) { $keys = is_array($keys) ? $keys : func_get_args(); $dictionary = Arr::except($this->getDictionary(), $keys); return new static(array_values($dictionary)); }
/** * Get the user for the given credentials. * * @param array $credentials * @return \Krucas\LaravelUserEmailVerification\Contracts\RequiresEmailVerification * * @throws \UnexpectedValueException */ public function getUser(array $credentials) { $credentials = Arr::except($credentials, ['token']); $user = $this->users->retrieveByCredentials($credentials); if ($user && !$user instanceof Contracts\RequiresEmailVerification) { throw new UnexpectedValueException('User must implement RequiresEmailVerification interface.'); } return $user; }
/** * Merge a configuration for a read / write connection. * * @param array $config * @param array $merge * @return array */ protected function mergeReadWriteConfig(array $config, array $merge) { return Arr::except(array_merge($config, $merge), ['read', 'write']); }
/** * Get all items except for those with the specified keys. * * @param mixed $keys * @return static */ public function except($keys) { return new static(Arr::except($this->items, $keys)); }
/** * Clone the model into a new, non-existing instance. * * @param array|null $except * @return \Illuminate\Database\Eloquent\Model */ public function replicate(array $except = null) { $except = $except ?: [$this->getKeyName(), $this->getCreatedAtColumn(), $this->getUpdatedAtColumn()]; $attributes = Arr::except($this->attributes, $except); $instance = new static(); $instance->setRawAttributes($attributes); return $instance->setRelations($this->relations); }
/** * Ends request and dispatch * * @return void */ public function dispatch() { $method = $this->original->getMethod(); $url = $this->server->get('api_url') . $this->getPath(); $headers = Arr::except($this->headers()->all(), ['cookie']); $this->request = $this->createClientRequest($method, $url, $headers); $this->request->end($this->getBufferEnd()); }
/** * Get all of the given array except for a specified array of items. * * @param array $array * @param array|string $keys * @return array */ function array_except($array, $keys) { return Arr::except($array, $keys); }
/** * @param $class * * @return array */ protected function getModelColumns($class) { $attributes = []; $namespace = $this->config->get('fractal.model_namespace'); $classNamespace = "\\{$namespace}\\{$class}"; if ($class) { if (class_exists($classNamespace)) { $model = new \ReflectionClass($classNamespace); if ($model->isSubclassOf('Illuminate\\Database\\Eloquent\\Model')) { $mdl = $this->app->make($classNamespace); $table = $mdl->getConnection()->getTablePrefix() . $mdl->getTable(); $schema = $mdl->getConnection()->getDoctrineSchemaManager($table); $database = null; if (strpos($table, '.')) { list($database, $table) = explode('.', $table); } $columns = Arr::except($schema->listTableColumns($table, $database), $mdl->getHidden()); foreach ($columns as $column) { if ($column->getType() instanceof \Doctrine\DBAL\Types\JsonArrayType) { continue; } $castTo = $this->getCasting($column->getType()); $attributes[] = ['column' => $column->getName(), 'casts' => $castTo]; } return $attributes; } } else { $this->error("Your model {$class} was not found in {$namespace}\\ \r\nIf this is the first time you get this message, try to update /config/fractal.php to make changes to model_namespace accordingly."); exit; } } // use as a default attribute return [['column' => 'id', 'casts' => null]]; }