/** * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\JsonResponse */ public function resolveIdsToNames(Request $request) { $ids = array_unique(explode(',', $request->ids)); // Init the initial return array $response = []; // Populate any entries from the cache foreach ($ids as $id) { if (Cache::has($this->prefix . $id)) { $response[$id] = Cache::get($this->prefix . $id); unset($ids[$id]); } } // Call the EVE API for any outstanding ids that need // resolution if (!empty($ids)) { $pheal = app()->make('Seat\\Eveapi\\Helpers\\PhealSetup')->getPheal(); foreach (array_chunk($ids, 30) as $id_chunk) { $names = $pheal->eveScope->CharacterName(['ids' => implode(',', $id_chunk)]); foreach ($names->characters as $result) { Cache::forever($this->prefix . $result->characterID, $result->name); $response[$result->characterID] = $result->name; } } } return response()->json($response); }
/** * Execute the console command. * * @return void */ public function fire() { $this->info('Migrating modules'); // Get all modules or 1 specific if ($moduleName = $this->input->getArgument('module')) { $modules = array(app('modules')->module($moduleName)); } else { $modules = app('modules')->modules(); } foreach ($modules as $module) { if ($module) { if ($this->app['files']->exists($module->path('migrations'))) { // Prepare params $path = ltrim(str_replace(app()->make('path.base'), '', $module->path()), "/") . "/migrations"; $_info = array('path' => $path); // Add to migration list array_push($this->migrationList, $_info); $this->info("Added '" . $module->name() . "' to migration list."); } else { $this->line("Module <info>'" . $module->name() . "'</info> has no migrations."); } } else { $this->error("Module '" . $moduleName . "' does not exist."); } } if (count($this->migrationList)) { $this->info("\n\t\t\t\tRunning Migrations..."); // Process migration list $this->runPathsMigration(); } if ($this->input->getOption('seed')) { $this->info("Running Seeding Command..."); $this->call('modules:seed'); } }
protected function getValidatorFromClass($class) { $className = get_class($class); $validatorClassName = app()['config']['laracruds']['validators-path'] . '\\' . explode("\\", $className)[1] . app()['config']['laracruds']['validators-sufix']; $validatorClass = new $validatorClassName($class); return $validatorClass; }
public function create(\Request $request) { $data = Request::json()->all(); $issue_service = new IssueService(app(ConfigurationInterface::class)); $url_parts = parse_url($data['worklog']['self']); $uri = $url_parts['path']; $regex = '~^/rest/api/./issue/(?P<issue_id>.*?)/(?P<ignore>.*?)/?$~'; $matched = preg_match($regex, $uri, $matches); if (!$matched) { return null; } $issue = $issue_service->get($matches['issue_id']); $project_key = $issue->fields->project->key; $project = Project::whereJiraKey($project_key)->first(); $employee = Staff::whereUserName($data['worklog']['author']['name'])->first(); //return $project; $time_spent = $data['worklog']['timeSpentSeconds']; $started = $data['worklog']['started']; $timelog_jira_id = $data['worklog']['id']; $timelog = Timelog::whereJiraId($timelog_jira_id)->first(); if ($timelog == null) { $timelog = new Timelog(); } $timelog->project_id = $project->id; $timelog->staff_id = $employee->id; $timelog->started = $started; $timelog->time_spent = $time_spent; $timelog->jira_id = $timelog_jira_id; $timelog->save(); //debugInfo($timelog); return $timelog; }
/** * Ready up blog repositories. */ public function __construct() { $this->blogCategoriesRepository = app(CategoriesRepositoryInterface::class); $this->blogPostsRepository = app(PostsRepositoryInterface::class); $this->blogTagsRepository = app(TagsRepositoryInterface::class); $this->callConstructor(); }
/** * Reverse the migrations. * * @return void */ public function down() { /* @var Builder $schema */ $schema = app('db')->connection()->getSchemaBuilder(); $schema->dropIfExists('streams_assignments'); $schema->dropIfExists('streams_assignments_translations'); }
/** * Create the migration * * @param string $name * @return bool */ protected function createMigration() { //Create the migration $app = app(); $migrationFiles = array($this->laravel->path . "/database/migrations/*_create_cities_table.php" => 'cities::generators.migration'); $seconds = 0; foreach ($migrationFiles as $migrationFile => $outputFile) { if (sizeof(glob($migrationFile)) == 0) { $migrationFile = str_replace('*', date('Y_m_d_His', strtotime('+' . $seconds . ' seconds')), $migrationFile); $fs = fopen($migrationFile, 'x'); if ($fs) { $output = "<?php\n\n" . $app['view']->make($outputFile)->with('table', 'cities')->render(); fwrite($fs, $output); fclose($fs); } else { return false; } $seconds++; } } //Create the seeder $seeder_file = $this->laravel->path . "/database/seeds/CitiesSeeder.php"; $output = "<?php\n\n" . $app['view']->make('cities::generators.seeder')->render(); if (!file_exists($seeder_file)) { $fs = fopen($seeder_file, 'x'); if ($fs) { fwrite($fs, $output); fclose($fs); } else { return false; } } return true; }
public function signMessage($address) { $input = Input::all(); $output = array(); if (!isset($input['message']) or trim($input['message']) == '') { $output['error'] = 'Message required'; $output['result'] = false; return new Response($output, 400); } $get = PaymentAddress::where('uuid', $address)->orWhere('address', $address)->first(); $found = false; if (!$get) { $output['error'] = 'Bitcoin address does not belong to server'; $output['result'] = false; return new Response($output, 400); } $address = $get->address; $address_generator = app('Tokenly\\BitcoinAddressLib\\BitcoinAddressGenerator'); $lib = new BitcoinLib(); $priv_key = $address_generator->WIFPrivateKey($get->private_key_token); $priv_key = BitcoinLib::WIF_to_private_key($priv_key); $sign = $priv_key; try { $sign = $lib->signMessage($input['message'], $priv_key); } catch (Exception $e) { $sign = false; } if (!$sign) { $output['error'] = 'Error signing message'; $output['result'] = false; return new Response($output, 500); } $output['result'] = $sign; return new Response($output); }
/** * @param \Illuminate\Console\Command $command * @param array $arguments * @return int */ protected function runCommand(Illuminate\Console\Command $command, array $arguments = []) { $command->setLaravel(app()); $input = new Symfony\Component\Console\Input\ArrayInput($arguments); $input->setInteractive(false); return $command->run($input, new Symfony\Component\Console\Output\NullOutput()); }
public function __construct() { $this->assetManager = app(AssetManager::class); $this->assetPipeline = app(AssetPipeline::class); $this->addAssets(); $this->requireDefaultAssets(); }
/** * Returns the event dispatcher. * * @return \Illuminate\Events\Dispatcher */ public static function getDispatcher() { if (!isset(static::$dispatcher)) { static::$dispatcher = function_exists('app') ? app(Dispatcher::class) : forward_static_call_array('Illuminate\\Container\\Container::make', [Dispatcher::class]); } return static::$dispatcher; }
/** * Performs the actual processing */ protected function doProcessing() { $this->prepareProcessContext(); // initialization process pipeline $initSteps = $this->initProcessSteps(); if (!empty($initSteps)) { $this->context = app(Pipeline::class)->send($this->context)->through($initSteps)->then(function (ProcessContextInterface $context) { return $context; }); $this->afterInitSteps(); } // main pipeline (actual processing) $steps = $this->processSteps(); if ($this->databaseTransaction) { DB::beginTransaction(); } try { $this->context = app(Pipeline::class)->send($this->context)->through($steps)->then(function (ProcessContextInterface $context) { if ($this->databaseTransaction) { DB::commit(); } return $context; }); } catch (Exception $e) { if ($this->databaseTransaction) { DB::rollBack(); } $this->onExceptionInPipeline($e); throw $e; } $this->afterPipeline(); $this->populateResult(); }
/** * Permintaan refresh token * * @param Request $request * @return array */ public function refreshToken(Request $request) { $this->middleware('auth'); $user = app('auth')->user(); $newToken = JWTAuth::parseToken()->refresh(); return ['status' => 'success', 'user' => $user, 'token' => $newToken]; }
/** * Register any application authentication / authorization services. * * @param \Illuminate\Contracts\Auth\Access\Gate $gate * @return void */ public function boot(GateContract $gate) { $this->registerPolicies($gate); app('auth')->provider('gladiator', function () { return new GladiatorUserProvider($this->app['hash'], config('auth.providers.gladiator.model')); }); }
public function handle() { $reader = app('excel.reader'); $reader->injectExcel(app('phpexcel')); $reader->_init($this->file); $filter = new ChunkReadFilter(); $reader->reader->setLoadSheetsOnly($this->sheets); $reader->reader->setReadFilter($filter); $reader->reader->setReadDataOnly(true); // Set the rows for the chunking $filter->setRows($this->startRow, $this->chunkSize); // Load file with chunk filter enabled $reader->excel = $reader->reader->load($this->file); // Slice the results $results = $reader->get()->slice($this->startIndex, $this->chunkSize); $callback = $this->shouldQueue ? (new Serializer())->unserialize($this->callback) : $this->callback; // Do a callback if (is_callable($callback)) { $break = call_user_func($callback, $results); } $reader->_reset(); unset($reader, $results); if ($break) { return true; } }
/** * Translate the given message. * * @param string $id * @param array $parameters * @param string $domain * @param string $locale * @return string */ function __($id = null, $parameters = [], $domain = 'messages', $locale = null) { if (is_null($id)) { return app('translator'); } return app('translator')->trans($id, $parameters, $domain, $locale); }
public function init() { $data = array('content' => array(), 'error' => Yii::t('main', 'Модуль отключен.')); if (config('forum_threads.allow') == 1) { $data = cache()->get(CacheNames::FORUM_THREADS); if ($data === FALSE) { $data = array(); try { // Подключаюсь к БД $this->db = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => 'mysql:host=' . config('forum_threads.db_host') . ';port=' . config('forum_threads.db_port') . ';dbname=' . config('forum_threads.db_name'), 'enableProfiling' => YII_DEBUG, 'enableParamLogging' => TRUE, 'username' => config('forum_threads.db_user'), 'password' => config('forum_threads.db_pass'), 'charset' => 'utf8', 'emulatePrepare' => TRUE, 'tablePrefix' => config('forum_threads.prefix'))); app()->setComponent('ForumThreadsDb', $this->db); $forumType = config('forum_threads.type'); if (method_exists($this, $forumType)) { $data['content'] = $this->{$forumType}(); foreach ($data['content'] as $k => $v) { $data['content'][$k]['user_link'] = $this->getUserLink($v['starter_id'], $v['starter_name']); $data['content'][$k]['theme_link'] = $this->getForumLink($v['id_topic'], $v['title'], $v['id_forum']); $data['content'][$k]['start_date'] = $this->getStartDate($v['start_date']); } if (config('forum_threads.cache')) { cache()->set(CacheNames::FORUM_THREADS, $data, config('forum_threads.cache') * 60); } } else { $data['error'] = Yii::t('main', 'Метод для обработки форума: :type не найден.', array(':type' => '<b>' . $forumType . '</b>')); } } catch (Exception $e) { $data['error'] = $e->getMessage(); } } } app()->controller->renderPartial('//forum-threads', $data); }
/** * render * * @return \Illuminate\Contracts\View\View */ public function render() { $args = $this->arguments; if (empty($args['id'])) { $args['id'] = ''; } if (empty($args['slug'])) { $args['slug'] = ''; } if (empty($args['slugDomName'])) { $args['slugDomName'] = 'slug'; } if (empty($args['titleDomName'])) { $args['titleDomName'] = 'title'; } if (empty($args['titleClassName'])) { $args['titleClassName'] = 'xe-form-control title'; } $args['scriptInit'] = false; if (self::$loaded === false) { self::$loaded = true; $args['scriptInit'] = true; } $plugin = app('xe.plugin.board'); return View::make(sprintf('%s::views.uiobject.title', $plugin->getId()), $args)->render(); }
public function showConnector() { $roots = $this->app->config->get('elfinder.roots', []); if (empty($roots)) { $dirs = (array) $this->app['config']->get('elfinder.dir', []); foreach ($dirs as $dir) { $roots[] = ['driver' => 'LocalFileSystem', 'path' => public_path($dir), 'URL' => url($dir), 'accessControl' => $this->app->config->get('elfinder.access')]; } $disks = (array) $this->app['config']->get('elfinder.disks', []); foreach ($disks as $key => $root) { if (is_string($root)) { $key = $root; $root = []; } $disk = app('filesystem')->disk($key); if ($disk instanceof FilesystemAdapter) { $defaults = ['driver' => 'Flysystem', 'filesystem' => $disk->getDriver(), 'alias' => $key]; $roots[] = array_merge($defaults, $root); } } } $opts = $this->app->config->get('elfinder.options', array()); $opts = array_merge(['roots' => $roots], $opts); // run elFinder $connector = new Connector(new \elFinder($opts)); $connector->run(); return $connector->getResponse(); }
/** * */ public function boot() { $this->app->singleton('moip-client', function () { return new MoipClient(config('moip-assinaturas.api_token'), config('moip-assinaturas.api_key'), config('moip-assinaturas.environment', 'api')); }); $this->app->singleton('moip-api', function () { return new Api(app('moip-client')); }); $this->app->bind('moip-plans', function () { return app('moip-api')->plans(); }); $this->app->bind('moip-subscriptions', function () { return app('moip-api')->subscriptions(); }); $this->app->bind('moip-customers', function () { return app('moip-api')->customers(); }); $this->app->bind('moip-invoices', function () { return app('moip-api')->invoices(); }); $this->app->bind('moip-preferences', function () { return app('moip-api')->preferences(); }); $this->app->bind('moip-payments', function () { return app('moip-api')->payments(); }); $this->publishes([__DIR__ . '/../../../config/config.php' => config_path('moip-assinaturas.php')]); }
/** * @param $item * @param bool $blocking * @param string $ctx * * @return string */ public function __invoke($item, $blocking = null, $ctx = 'btn') { if (!$item instanceof User) { return ''; } if (!app()->auth()->logged()) { return ''; } if (!app()->aclService()->authorize('core.block_other')) { return ''; } if (app()->auth()->getId() == $item->getId()) { return ''; } $poster = app()->auth()->getViewer(); if (null === $blocking) { $service = app()->instance()->make('core.block'); if ($service instanceof BlockService) { } $blocking = $service->isBlocked($poster, $item); } switch ($ctx) { case 'menu': case 'menu-item': $script = 'platform/core/partial/menu-item-block'; break; default: $script = 'platform/core/partial/button-block'; } return app()->viewHelper()->partial($script, ['blocking' => $blocking, 'attrs' => ['id' => $item->getId(), 'type' => $item->getType()]]); }
public function index($fk = null) { $this->repository->pushCriteria(app(RequestCriteria::class)); $list = $this->repository->paginate(); $this->description = "Listar/Pesquisar Registros"; return view($this->prefix . ".index", ["breadcrumb" => $this->breadcrumbs, "title" => $this->title, "description" => $this->description, "columns" => $this->columns, "list" => $list, "prefix" => $this->prefix, "fk" => $fk, "relation" => $this->relation]); }
protected function processMany(Request $request, $id, $method) { $parent = $this->findParentEntity($id); $requestCollection = $request->json()->all(); $this->validateRequestCollection($requestCollection, $this->getChildModel(), true); $existingChildren = $this->findChildrenCollection($requestCollection, $parent); $childModels = $this->fillModels($this->getChildModel(), $existingChildren, $requestCollection); $this->checkPermission(static::class . '@' . $method . 'Many', ['model' => $parent, 'children' => $childModels]); $this->preSync($parent, $childModels); $this->saveNewItemsInCollection($childModels); /** @var ElasticSearchIndexer $searchIndexer */ $searchIndexer = app(ElasticSearchIndexer::class); $reindexItems = $searchIndexer->mergeUniqueCollection($searchIndexer->getAllItemsFromRelations($parent, [$this->relationName]), $childModels); $this->getRelation($parent)->{$method}($this->makeSyncList($childModels, $requestCollection)); $this->postSync($parent, $childModels); // Reindex parent entity without relations $searchIndexer->reindexOne($parent, []); // Reindex all affected items without relations $searchIndexer->reindexMany($reindexItems, []); $transformed = $this->getTransformer()->transformCollection($this->findAllChildren($parent), ['_self']); $responseCollection = collect($transformed)->map(function ($entity) { return ['_self' => $entity['_self']]; })->toArray(); return $this->getResponse()->collection($responseCollection, ApiResponse::HTTP_CREATED); }
/** * Resets/initializes the interpreted response to a fresh instance * with default values */ protected function resetInterpretedResponse() { $this->interpretedResponse = app(ServiceResponse::class); $this->interpretedResponse->setStatusCode(0); $this->interpretedResponse->setErrors([]); $this->interpretedResponse->setData(null); }
/** * Загрузка конфигурационных файлов из БД с заменой ключей */ public function boot() { $config = DatabaseConfig::get(); foreach ($config as $group => $data) { app('config')->set($group, array_merge(config($group, []), $data)); } }
/** * Attempts to authenticate the user. * * @param \App\Models\User\User $user * @param \Illuminate\Auth\Guard $auth * * @return \Illuminate\Http\RedirectResponse */ public function callback(User $user, Guard $auth) { try { $payload = $this->socialite->user(); } catch (Exception $e) { $this->flash('Failed to sign in via GitHub, did you decline?', Controller::FLASH_ERROR); return redirect()->route('get::front.home'); } try { $response = app('GuzzleHttp\\Client')->get('https://api.github.com/user/emails?access_token=' . $payload->token, ['headers' => ['Accept' => 'application/vnd.github.v3+json']]); $emails = $response->json(); } catch (Exception $e) { $this->flash('Failed to sign in via GitHub, is your GitHub account verified?', Controller::FLASH_ERROR); return redirect()->route('get::front.home'); } $email = array_filter($emails, function ($email) { return $email['primary']; }); if (count($email) === 0) { $this->flash('Failed to sign in via GitHub, is your GitHub account verified?', Controller::FLASH_ERROR); return redirect()->route('get::front.home'); } $email = array_get(array_values($email)[0], 'email'); $user = $user->firstOrCreate(['uid' => $payload->id]); $user->update(['token' => $payload->token, 'email' => $email, 'nickname' => $payload->nickname, 'name' => $payload->nickname]); $auth->login($user, true); return redirect()->intended('/home'); }
/** * Register the blade directives * * @return void */ private function bladeDirectives() { $blade = app('view')->getEngineResolver()->resolve('blade')->getCompiler(); // Call to Lumineer::hasRole $blade->directive('role', function ($expression) { return "<?php if (lumineer()->hasRole{$expression}) : ?>"; }); $blade->directive('endrole', function ($expression) { return "<?php endif; ?>"; }); // Call to Lumineer::can $blade->directive('permission', function ($expression) { return "<?php if (lumineer()->can{$expression}) : ?>"; }); $blade->directive('endpermission', function ($expression) { return "<?php endif; ?>"; }); // Call to Lumineer::ability $blade->directive('ability', function ($expression) { return "<?php if (lumineer()->ability{$expression}) : ?>"; }); $blade->directive('endability', function ($expression) { return "<?php endif; ?>"; }); }
/** * @param ImageFactoryInterface $imageFactory * @param ThumbnailsManager $manager */ public function __construct(ImageFactoryInterface $imageFactory, ThumbnailsManager $manager) { $this->image = app(ImageManager::class); $this->filesystem = app(Factory::class); $this->imageFactory = $imageFactory; $this->manager = $manager; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param $permission * * @return mixed */ public function handle($request, Closure $next, $permission) { if (!current_user_can($permission) || is_logged_out()) { app()->abort(403, 'You do not have enough permissions to access this page.'); } return $next($request); }
/** * Set the app attribute using the global $app variable */ public function __construct() { $this->app = app(); $aws = $this->app->make('Aws\\Common\\Aws'); $config = $this->buildConfig(); $this->aws = $aws->factory($config); }