/** * Get the configuration data. * * @param string[] $config * * @throws \InvalidArgumentException * * @return string */ protected function getConfig(array $config) { if (!array_key_exists('token', $config)) { throw new \InvalidArgumentException('The GitLab client requires configuration.'); } return array_only($config, ['token', 'base_url', 'method', 'sudo']); }
/** * Get the configuration data. * * @param string[] $config * * @throws \InvalidArgumentException * * @return array */ protected function getConfig(array $config) { if (!array_key_exists('client_id', $config)) { throw new InvalidArgumentException('Missing configuration key [client_id].'); } return array_only($config, ['client_id', 'client_secret', 'callback_url']); }
/** * Get the configuration. * * @param string[] $config * * @throws \InvalidArgumentException * * @return string[] */ protected function getConfig(array $config) { if (!array_key_exists('token', $config) || !array_key_exists('email', $config)) { throw new \InvalidArgumentException('The cloudflare client requires configuration.'); } return array_only($config, ['token', 'email']); }
/** * Transform row data by columns definition. * * @param array $row * @param mixed $columns * @param string $type * @return array */ public function transform(array $row, $columns, $type = 'printable') { if ($columns instanceof Collection) { return $this->buildColumnByCollection($row, $columns, $type); } return array_only($row, $columns); }
public function testStore() { $project = Factory::build('Project', ['name' => 'Foo']); $input = array_only($project->getAttributes(), $project->getFillable()); $this->action('POST', 'Admin\\ProjectsController@store', $input); $this->assertRedirectedToRoute('admin.projects.show', 'foo'); }
/** * Creates a new Lavary\Menu\MenuItem instance. * * @param string $title * @param string $url * @param array $attributes * @param int $parent * @param \Lavary\Menu\Menu $builder * @return void */ public function __construct($builder, $id, $title, $options) { $this->builder = $builder; $this->id = $id; $this->title = $title; $this->nickname = camel_case($title); $this->attributes = $this->builder->extractAttributes($options); $this->parent = is_array($options) && isset($options['parent']) ? $options['parent'] : null; // Storing path options with each link instance. if (!is_array($options)) { $path = array('url' => $options); } elseif (isset($options['raw']) && $options['raw'] == true) { $path = null; } else { $path = array_only($options, array('url', 'route', 'action', 'secure')); } if (!is_null($path)) { $path['prefix'] = $this->builder->getLastGroupPrefix(); } $this->link = $path ? new Link($path) : null; // Activate the item if items's url matches the request uri if (true === $this->builder->conf('auto_activate')) { $this->checkActivationStatus(); } }
/** * Get the configuration data. * * @param string[] $config * * @throws \InvalidArgumentException * * @return string[] */ protected function getConfig(array $config) { if (!array_key_exists('app_key', $config) || !array_key_exists('app_secret', $config)) { throw new \InvalidArgumentException('The top client requires api keys.'); } return array_only($config, ['app_key', 'app_secret', 'format']); }
public function verifyAndCreate($data) { $compcat = $this->compcat->verifyAndCreate(array_only($data, ['supno', 'catname'])); $attr = ['code' => 'new', 'descriptor' => $data['comp'], 'compcatid' => $compcat->id, 'cost' => $data['ucost'], 'uom' => $data['unit']]; //return $this->firstOrNew($attr, ['descriptor']); return $this->findOrNew($attr, ['descriptor']); }
public static function register(array $input) : User { $defaults = ['role' => UserRole::MEMBER(), 'status' => UserStatus::ACTIVE()]; $user = static::create($defaults + array_only($input, ['first_name', 'last_name', 'address', 'postal', 'city', 'country', 'telephone', 'email', 'password'])); event(new UserRegistered($user)); return $user; }
/** * Get the configuration. * * @param string[] $config * * @return string[] */ protected function getConfig(array $config) { if (!array_key_exists('container', $config)) { throw new InvalidArgumentException('The azure connector requires container configuration.'); } return array_only($config, ['container']); }
/** * Bind data to the view. * * @param View $view * * @return void */ public function compose(View $view) { $data = $view->getData(); if (Auth::check()) { $notifications = Auth::user()->notifications()->with('user')->orderBy('created_at', 'desc')->take(15)->get(); $view->with('notifications', $notifications); $unreadCount = Auth::user()->notifications()->wherePivot('read', false)->count(); $view->with('newNotificationsCount', $unreadCount); } // Get object from which we can extract name to use as page title $currentGroup = head(array_only($data, ['group', 'folder', 'fakeGroup'])); $view->with('currentGroup', $currentGroup); if (isset($currentGroup) && isset($currentGroup->name)) { $pageTitle = $currentGroup->name; // Homepage title shall always be Strimoid.pl if ($currentGroup->urlname == 'all' && !Setting::get('homepage_subscribed', false)) { $pageTitle = 'Strimoid'; } if ($currentGroup->urlname == 'subscribed' && Setting::get('homepage_subscribed', false)) { $pageTitle = 'Strimoid'; } } else { $pageTitle = 'Strimoid'; } $view->with('pageTitle', $pageTitle); // Needed by top bar with groups $popularGroups = Cache::remember('popularGroups', 60, function () { return Group::orderBy('subscribers_count', 'desc', true)->take(30)->get(['id', 'name', 'urlname']); }); $view->with('popularGroups', $popularGroups); }
/** * Get a subset of the items from the input data. * * @param array $keys * * @return array */ public function only($keys) { $keys = is_array($keys) ? $keys : func_get_args(); $results = $this->input(); $results = is_array($results) ? $results : array(); return array_only($results, $keys) + array_fill_keys($keys, null); }
/** * Get the configuration data. * * @param string[] $config * * @throws \InvalidArgumentException * * @return array */ protected function getConfig(array $config) { if (!array_key_exists('consumer_key', $config)) { throw new \InvalidArgumentException('The Twitter API client requires configuration.'); } return array_only($config, ['consumer_key', 'consumer_secret', 'access_token', 'access_token_secret']); }
public function testStore() { $user = Factory::build('User'); $input = array_only($user->getAttributes(), $user->getFillable()); $this->action('POST', 'Admin\\UsersController@store', $input); $this->assertRedirectedToRoute('admin.users.show', User::first()->id); }
private function setMetaDataOnCollection() { $this->meta = []; if (isset($this->originalParsedData['ast'])) { $this->meta = array_only($this->originalParsedData['ast'], ['metadata', 'name', 'description']); } }
/** * Get the configuration. * * @param string[] $config * * @throws \InvalidArgumentException * * @return string[] */ protected function getConfig(array $config) { if (!array_key_exists('path', $config)) { throw new InvalidArgumentException('The zip connector requires path configuration.'); } return array_only($config, ['path']); }
/** * Get the configuration. * * @param string[] $config * * @throws \InvalidArgumentException * * @return string[] */ protected function getConfig(array $config) { if (!array_key_exists('token', $config)) { throw new InvalidArgumentException('The guzzle connector requires configuration.'); } return array_only($config, ['token']); }
/** * Get the configuration data. * * @param string[] $config * * @throws \InvalidArgumentException * * @return array */ protected function getConfig(array $config) { if (!array_key_exists('client_id', $config)) { throw new \InvalidArgumentException('The Instagram client requires configuration.'); } return array_only($config, ['client_id', 'client_secret', 'callback_url']); }
/** * Get the configuration. * * @param string[] $config * * @return string[] */ protected function getConfig(array $config) { if (!array_key_exists('prefix', $config)) { $config['prefix'] = null; } return array_only($config, ['prefix']); }
/** * @param string $type * @param array $settings */ public function __construct($type, array $settings) { foreach (array_only($settings, ['class', 'type', 'title']) as $key => $value) { $this->{$key} = $value; } $this->type = $type; }
/** * 登入方法 * @param null $input * @return array */ public function login($input = null) { $input = $input ? $input : rq(); if (!empty($input['user_type']) && $input['user_type'] == 'doctor' && !empty($input['cust_id'])) { $d = M('doctor'); $d = $d->where('cust_id', $input['cust_id'])->first(); if ($d) { log_him_in(['uid' => $d->id]); add_chara($input['user_type']); return ss(); } return $d ? ss($d) : ee(2); } if (!empty($input['user_type']) && !empty($input['username']) && !empty($input['password'])) { $input['password'] = hash_password($input['password']); $user = $this->user_exists($input['user_type'], array_only($input, ['username', 'password'])); if ($user) { log_him_in(['username' => $user->username, 'uid' => $user->id]); add_chara($input['user_type']); return ss(); } } else { return ee(2); } return ee(2); }
public function testLogging() { Log::log('info', 'testing', ['context' => 'context']); $entry = LogModel::first(); $expected = ['id' => '1', 'read' => '0', 'message' => 'testing', 'context' => '{"context":"context"}', 'level' => '200', 'level_name' => 'INFO', 'channel' => 'testing', 'extra' => '[]']; $this->assertEquals($expected, array_only($entry->getAttributes(), array_keys($expected))); }
public static function addBeforeFilter($controller, $method, $args) { $method = last(explode('::', $method)); $resourceName = array_key_exists(0, $args) ? snake_case(array_shift($args)) : null; $lastArg = last($args); if (is_array($lastArg)) { $args = array_merge($args, array_extract_options($lastArg)); } $options = array_extract_options($args); if (array_key_exists('prepend', $options) && $options['prepend'] === true) { $beforeFilterMethod = "prependBeforeFilter"; unset($options['prepend']); } else { $beforeFilterMethod = "beforeFilter"; } $resourceOptions = array_except($options, ['only', 'except']); $filterPrefix = "router.filter: "; $filterName = "controller." . $method . "." . get_classname($controller) . "(" . md5(json_encode($args)) . ")"; $router = App::make('router'); if (!Event::hasListeners($filterPrefix . $filterName)) { $router->filter($filterName, function () use($controller, $method, $resourceOptions, $resourceName) { $controllerResource = App::make('Efficiently\\AuthorityController\\ControllerResource', [$controller, $resourceName, $resourceOptions]); $controllerResource->{$method}(); }); call_user_func_array([$controller, $beforeFilterMethod], [$filterName, array_only($options, ['only', 'except'])]); } }
/** * Get the configuration data. * * @param string[] $config * * @throws \InvalidArgumentException * * @return string[] */ protected function getConfig(array $config) { if (!array_key_exists('token', $config) || !array_key_exists('app', $config)) { throw new InvalidArgumentException('The dropbox client requires authentication.'); } return array_only($config, ['token', 'app']); }
/** * @param string $type * @param array $settings */ public function __construct($type, array $settings) { foreach (array_only($settings, ['class', 'type', 'title', 'icon', 'category', 'edit_template', 'document_template', 'widget_template']) as $key => $value) { $this->{$key} = $value; } $this->type = $type; }
/** * Get the configuration data. * * @param string[] $config * * @throws \InvalidArgumentException * * @return array */ protected function getConfig(array $config) { if (!array_key_exists('developer_key', $config)) { throw new \InvalidArgumentException('The Google API client requires configuration.'); } return array_only($config, ['developer_key']); }
/** * @param array $properties */ private function setProperties(array $properties) { $this->properties = []; if (isset($properties)) { $this->properties = array_only($properties, ['name', 'description', 'uriTemplate', 'parameters']); } }
/** * Update the business service types. * * @param Business $business * @param Request $request * * @return Response */ public function update(Business $business, Request $request) { logger()->info(__METHOD__); logger()->info(sprintf('businessId:%s', $business->id)); $this->authorize('manageServices', $business); // BEGIN $servicetypeSheet = $request->input('servicetypes'); $regex = '/(?P<name>[a-zA-Z\\d\\-\\ ]+)\\:(?P<description>[a-zA-Z\\d\\ ]+)/im'; preg_match_all($regex, $servicetypeSheet, $matches, PREG_SET_ORDER); $publishing = collect($matches)->map(function ($item) { $data = array_only($item, ['name', 'description']); $data['slug'] = str_slug($data['name']); return $data; }); foreach ($business->servicetypes as $servicetype) { if (!$this->isPublished($servicetype, $publishing)) { $servicetype->delete(); } } foreach ($publishing as $servicetypeData) { $servicetype = ServiceType::firstOrNew($servicetypeData); $business->servicetypes()->save($servicetype); } flash()->success(trans('servicetype.msg.update.success')); return redirect()->route('manager.business.service.index', [$business]); }
/** * Make a new validator instance for this model. * * @param array $attributes * @return \Illuminate\Validation\Validator */ protected function makeValidator(array $attributes) { $rules = array_only($this->getRules(), array_keys($attributes)); $validator = $this->validator->make($attributes, $rules, $this->getMessages()); $this->events->fire(new ConfigureValidator($this, $validator)); return $validator; }
/** * Execute the console command. * * @return mixed * @throws \Gitonomy\Git\Exception\RuntimeException * @throws \Gitonomy\Git\Exception\InvalidArgumentException */ public function handle() { $inspector = new Inspector($this->settings); $repository = $inspector->getRepositoryByUrl($this->argument('repositoryUrl')); $inspectedRepository = $inspector->inspectRepository($repository); $header = array_keys((array) $inspectedRepository[key($inspectedRepository)]); if (!$this->option('dry-run')) { $remote = $inspectedRepository['remote']; \Swis\GotLaravel\Models\Results::unguard(); foreach ($inspectedRepository['results'] as $result) { $insert = $result->toArray(); $insert['remote'] = $remote; $insert['author_slug'] = Str::slug($result->getAuthor()); $insert['created_at'] = Carbon::createFromTimestamp($insert['date']); try { \Swis\GotLaravel\Models\Results::updateOrCreate(array_only($insert, ['remote', 'filename', 'line']), $insert); } catch (\Exception $e) { $this->error('Couldnt insert: ' . $e->getMessage() . PHP_EOL . print_r($insert, 1)); } } } reset($inspectedRepository['results']); array_walk($inspectedRepository['results'], function (&$row) { $row = $row->toArray(); }); $this->info($inspectedRepository['remote']); $this->table($header, $inspectedRepository['results']); Artisan::call('got:normalize-names'); }