/** * Execute the console command. * * @return mixed */ public function fire() { $lrs_collection = (new Lrs())->get(); // Remove all inactive statements. Statement::where('active', '=', false)->delete(); // Migrates the statements for each LRS. foreach ($lrs_collection as $lrs) { Statement::where('lrs._id', $lrs->_id)->chunk(500, function ($statements) use($lrs) { $statements_array = []; // Sets `active` and `voided` properties. // Ensures that statement is an associative array. $statements = $statements->each(function ($statement) { $statement->voided = isset($statement->voided) ? $statement->voided : false; $statement->active = isset($statement->active) ? $statement->active : true; $statement->save(); $statements_array[] = (array) json_decode($statement->toJSON()); }); // Uses the repository to migrate the statements. $repo = App::make('Locker\\Repository\\Statement\\EloquentVoider'); $repo->updateReferences($statements_array, $lrs); $repo->voidStatements($statements_array, $lrs); // Outputs status. $statement_count = $statements->count(); $this->info("Migrated {$statement_count} statements in `{$lrs->title}`."); }); } $this->info('All statements migrated.'); }
/** * Execute the job. * @return void */ public function handle() { $s3 = \App::make('aws'); $s3->createClient('s3')->putObject(['Bucket' => 'transcoderinput435983', 'Key' => $this->key_input, 'SourceFile' => storage_path() . '/app/' . $this->key_input]); $s3->createClient('ElasticTranscoder')->createJob(['PipelineId' => env('PIPLINE_ID'), 'Input' => ['Key' => $this->key_input, 'FrameRate' => 'auto', 'Resolution' => 'auto', 'AspectRatio' => 'auto', 'Interlaced' => 'auto', 'Container' => 'auto'], 'Output' => ['Key' => $this->key_output, 'ThumbnailPattern' => $this->time . '_thumb{count}', 'Rotate' => 'auto', 'PresetId' => '1452215960232-me3asn']]); \File::delete(storage_path() . '/app/' . $this->key_input); }
/** * Saves all datamodels in all services to the database. */ public function save() { $data = $this->getData(); $repo = \App::make(YoutubeRepository::class); call_user_func([$repo, 'save' . ucfirst(str_plural($this->_params->get('resource')['name']))], $data); event(new PackageSaved($this)); }
/** * Create a new command instance. * * @return void */ function __construct() { parent::__construct(); $this->prod_delete_req_repo = App::make('Giftertipster\\Repository\\ProductDeleteRequest\\ProductDeleteRequestRepositoryInterface'); $this->prod_suite_repo = App::make('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface'); $this->cache_refresher = App::make('Giftertipster\\Service\\Cache\\CacheRefresherInterface'); }
public function __construct($name, $payload = null) { $this->name = $name; $this->aggregate_hash = \App::make('guid.aggregate_hash'); $this->payload = new EventPayload($payload); $this->logger = new EventLogger($this); }
public function __construct() { $dashboard = App::make('Lib\\Repositories\\Dashboard\\DashboardRepositoryInterface'); $validator = App::make('Lib\\Services\\Validation\\DashboardValidator'); $scraper = App::make('Lib\\Services\\Scraping\\Scraper'); parent::__construct($dashboard, $validator, $scraper); }
/** * Bootstrap the application events. * * @return void */ public function boot() { $this->package('djbarnes/l4-ldap-auth'); \Auth::extend('l4-ldap-auth', function () { return new Guard(new L4LdapAuthUserProvider(\Config::get('l4-ldap-auth::ldapserver'), \Config::get('l4-ldap-auth::ldapadmindn'), \Config::get('l4-ldap-auth::ldapadminpw'), \Config::get('l4-ldap-auth::searchbase'), \Config::get('l4-ldap-auth::searchfield')), \App::make('session')); }); }
public function testToGenerateService(UnitTester $I) { $client = \App::make('Stigma\\Nagios\\Client'); $data = []; $response = $client->generateService($data); $I->assertEquals('200', $response); }
public function __construct(array $attributes = []) { parent::__construct($attributes); $this->errors = new \Illuminate\Support\MessageBag(); $this->validator = \App::make('validator'); $this->manejaConcurrencia = true; }
public function sitemap() { // create new sitemap object $sitemap = \App::make('sitemap'); $date = new \DateTime(); // set cache key (string), duration in minutes (Carbon|Datetime|int), turn on/off (boolean) // by default cache is disabled $sitemap->setCache('laravel.sitemap', 60); // check if there is cached sitemap and build new only if is not if (!$sitemap->isCached()) { // add item with translations (url, date, priority, freq, images, title, translations) $translations = [['language' => 'en', 'url' => \URL::to('/en')], ['language' => 'zh-CN', 'url' => \URL::to('/zh-CN')], ['language' => 'zh-HK', 'url' => \URL::to('/zh-HK')]]; $sitemap->add(\URL::to('/'), $date->format('Y-m-d') . 'T00:00:00+08:00', '1', 'weekly', [], null, $translations); $translations = [['language' => 'en', 'url' => \URL::to('/en/portfolio')], ['language' => 'zh-CN', 'url' => \URL::to('/zh-CN/作品集')], ['language' => 'zh-HK', 'url' => \URL::to('/zh-HK/作品集')]]; $sitemap->add(\URL::to('/作品集'), $date->format('Y-m-d') . 'T00:00:00+08:00', '0.9', 'weekly', [], null, $translations); $translations = [['language' => 'en', 'url' => \URL::to('/en/freelance-HK')], ['language' => 'zh-CN', 'url' => \URL::to('/zh-CN/香港freelance')], ['language' => 'zh-HK', 'url' => \URL::to('/zh-HK/香港freelance')]]; $sitemap->add(\URL::to('/香港freelance'), $date->format('Y-m-d') . 'T00:00:00+08:00', '0.9', 'weekly', [], null, $translations); $translations = [['language' => 'en', 'url' => \URL::to('/en/web-design-host-seo')], ['language' => 'zh-CN', 'url' => \URL::to('/zh-CN/网页设计-寄存-SEO')], ['language' => 'zh-HK', 'url' => \URL::to('/zh-HK/網頁設計-寄存-SEO')]]; $sitemap->add(\URL::to('/網頁設計-寄存-SEO'), $date->format('Y-m-d') . 'T00:00:00+08:00', '0.9', 'weekly', [], null, $translations); $translations = [['language' => 'en', 'url' => \URL::to('/en/choose-online-partner')], ['language' => 'zh-CN', 'url' => \URL::to('/zh-CN/网站顾问')], ['language' => 'zh-HK', 'url' => \URL::to('/zh-HK/網站顧問')]]; $sitemap->add(\URL::to('/網站顧問'), $date->format('Y-m-d') . 'T00:00:00+08:00', '0.9', 'weekly', [], null, $translations); $translations = [['language' => 'en', 'url' => \URL::to('/en/contact-freelance')], ['language' => 'zh-CN', 'url' => \URL::to('/zh-CN/联络freelance')], ['language' => 'zh-HK', 'url' => \URL::to('/zh-HK/聯絡freelance')]]; $sitemap->add(\URL::to('/聯絡freelance'), $date->format('Y-m-d') . 'T00:00:00+08:00', '0.9', 'weekly', [], null, $translations); } // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf') return $sitemap->render('xml'); }
/** * Get the available container instance. * * @param string $key * @return mixed|\Slim\Slim */ function slim($key = '') { if (is_null($key)) { return App::container; } return App::make($key); }
public function test_it_persists_a_todolist_for_a_given_user() { $user = \Laracasts\TestDummy\Factory::create(App\Umbrella\User\User::class); $todolistRepo = App::make('App\\Umbrella\\Todo\\Repository\\TodolistRepositoryInterface'); $todolist = $todolistRepo->create('Private', $user); $this->seeInDatabase('todolist', ['name' => 'Private']); }
public function setUp() { parent::setUp(); \App::bind("App\\Repositories\\RecipeRepositoryInterface", "App\\Tests\\StubRepositories\\RecipeRepository"); \App::bind("App\\Presenter\\FeedInterface", "App\\Presenter\\Feed"); $this->controller = new FeedController(\App::make("App\\Presenter\\FeedInterface"), \App::make("App\\Repositories\\RecipeRepositoryInterface")); }
/** * Execute the console command. * * @return void */ public function fire() { $asset = \App::make('asset'); $asset->styles(); $asset->scripts(); $this->line('Generated and published assets'); }
public function setUp() { // During the parent's setup, both a 'es' 'Spanish' and 'en' 'English' languages are inserted into the database. parent::setUp(); $this->languageRepository = \App::make(LanguageRepository::class); $this->translationRepository = \App::make(TranslationRepository::class); }
private function saveToIndex(array $model_config) { if (empty($model_config['setup']['mapping']['properties'])) { throw new \InvalidArgumentException('Index model ' . self::$index_model . ' mapping properties found or empty in index config file.'); } $properties_config = $model_config['setup']['mapping']['properties']; //go through index properties / columns in config and capture values from model for indexing foreach ($properties_config as $column => $column_mapping) { //if the column is not set on the model but there is a mutator, //then use that to get value for indexing if (!isset($this->{$column}) && method_exists($this, 'set' . studly_case($column) . 'Attribute')) { $columns[$column] = $this->{'set' . studly_case($column) . 'Attribute'}(null); continue; } //if the column is not set on the model and there is no mutator throw exception if (!isset($this->{$column})) { throw new \InvalidArgumentException('Field ' . $column . ' does not exist for indexoing on this eloquent object.'); } //lastly, use column value that exists on model $columns[$column] = $this->{$column}; } if (!isset($this->id)) { var_dump($this); throw new \InvalidArgumentException('Eloquent id field missing for indexing.'); } $columns['_id'] = $this->id; $index_repo = \App::make('Ryanrobertsname\\LaravelElasticsearchRepository\\Repository\\IndexRepository'); $index_repo->model(self::$index_model)->index($columns); }
public function setUp() { $this->createApplication(); parent::setUp(); $this->mockHtmldom = $this->mock('App\\Libros\\Htmldom'); $this->reviews = App::make('App\\Libros\\Reviews'); }
/** * Execute the console command. * * @return mixed */ public function fire() { $keySize = $this->option('keySize'); // openssl is not working now $method = 'php'; switch ($method) { case 'php': $generator = \App::make('cryptoapi.generator.php'); break; case 'openssl': $generator = \App::make('cryptoapi.generator.openssl'); break; default: $this->error('Unknown key generation method specified.'); $this->error('Supported methods are: php, openssl'); exit; break; } $path = 'app/keys'; if (!is_dir($path)) { $this->info('Creating directory ' . $path); mkdir($path); } $this->info('Generating keypair using ' . $keySize . ' key size'); $generator->generateKeyPair($path, $keySize); $this->info("Keys were successfully generated in " . $path); }
/** * Check for added admin menu's */ public function __construct() { // Get loaded providers $providers = array_keys(\App::getLoadedProviders()); // Get Tdt matches, but not core $packages = preg_grep('/^Tdt[\\\\](?!Core)/i', $providers); $menu = $this->core_menu; // Check for UI controller foreach ($packages as $package) { // Get package namespace $reflector = new \ReflectionClass($package); $namespace = $reflector->getNamespaceName(); // Check for a UI controller $controller = $namespace . "\\Ui\\UiController"; if (class_exists($controller)) { // Create controller instance $controller = \App::make($controller); $package_menu = @$controller->menu(); // Check for added menu items if (!empty($package_menu)) { $menu = array_merge($menu, $package_menu); } // Push for future use array_push($this->package_controllers, $controller); } } // Sort menu's usort($menu, function ($a, $b) { return $a['priority'] - $b['priority']; }); // Share menu with views \View::share('menu', $menu); }
/** * Register the service provider. * * @return void */ public function register() { $app = $this->app; $app->bind('Faxbox\\Repositories\\Fax\\FaxInterface', 'Faxbox\\Repositories\\Fax\\EloquentFaxRepository'); $app->bind('Faxbox\\Repositories\\Phone\\PhoneInterface', 'Faxbox\\Repositories\\Phone\\EloquentPhoneRepository'); $app->bind('Faxbox\\Repositories\\Number\\NumberInterface', 'Faxbox\\Repositories\\Number\\EloquentNumberRepository'); $app->bind('Faxbox\\Repositories\\Setting\\SettingInterface', 'Faxbox\\Repositories\\Setting\\LaravelConfigSettingRepository'); $this->app['setting'] = $this->app->share(function ($app) { return \App::make('Faxbox\\Repositories\\Setting\\SettingInterface'); }); $app->singleton('Faxbox\\Repositories\\Permission\\PermissionInterface', 'Faxbox\\Repositories\\Permission\\PermissionRepository'); $app->bind('Faxbox\\Repositories\\File\\FileInterface', 'Faxbox\\Repositories\\File\\FileRepository'); $app->bind('Faxbox\\Repositories\\Mail\\MailInterface', 'Faxbox\\Repositories\\Mail\\MailRepository'); $this->app['permission'] = $this->app->share(function ($app) { return \App::make('Faxbox\\Repositories\\Permission\\PermissionInterface'); }); // Shortcut so developers don't need to add an Alias in app/config/app.php $this->app->booting(function () { $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Permission', 'Faxbox\\Facades\\Permission'); }); // Bind the Session Repository $app->bind('Faxbox\\Repositories\\Session\\SessionInterface', function ($app) { return new SentrySession($app['sentry']); }); // Bind the Group Repository $app->bind('Faxbox\\Repositories\\Group\\GroupInterface', function ($app) { return new SentryGroup($app['sentry'], \App::make('Faxbox\\Repositories\\Permission\\PermissionInterface')); }); // Bind the User Repository $app->bind('Faxbox\\Repositories\\User\\UserInterface', function ($app) { return new SentryUser($app['sentry']); }); }
/** * Initialize the instance. * * @param array $parsers * @return void */ public function __construct(array $parsers = null, Application $app = null) { $this->app = $app ?: \App::make('app'); if (!is_null($parsers)) { $this->addParsers($parsers); } }
/** * Initialize the instance * * @param string $file * @param \Hpkns\FrontMatter\Parser $frontMatter * @return void */ public function __construct(array $default = [], $strict = false, FrontMatter $frontMatter = null) { $this->frontMatter = $frontMatter ?: \App::make('Hpkns\\FrontMatter\\Parser'); if (!empty($default)) { $this->withDefault($default, $strict); } }
/** * Run the database seeds. * * @return void */ public function run() { $allNewSamplings = array(); $faker = App::make(Faker\Generator::class); $humiditySensors = App\GenericSensor::with("sensors")->where("alias", "Humidity")->first()->sensors; $temperatureSensors = App\GenericSensor::with("sensors")->where("alias", "Temperature")->first()->sensors; $everyDate = array(); $timeThreshold = 10; // minutes $numberOfDays = 2; $numberOfLoop = 24 * 60 / $timeThreshold; $samplingTime = Carbon::now(); foreach (range(0, $numberOfDays - 1) as $day) { foreach (range(0, $numberOfLoop - 1) as $time) { array_push($everyDate, $samplingTime->copy()); $samplingTime->subMinutes($timeThreshold); } } foreach ($humiditySensors as $humiditySensor) { foreach ($everyDate as $samplingDate) { array_push($allNewSamplings, array('sensor_id' => $humiditySensor->getKey(), 'sampled' => $faker->randomFloat(2, 20, 60), 'created_at' => $samplingDate)); } } foreach ($temperatureSensors as $temperatureSensor) { foreach ($everyDate as $samplingDate) { array_push($allNewSamplings, array('sensor_id' => $temperatureSensor->getKey(), 'sampled' => $faker->randomFloat(2, 19, 24), 'created_at' => $samplingDate)); } } DB::table('samplings')->insert($allNewSamplings); }
public function postSignupConfirm() { if (!Session::has('userGithubData')) { return $this->redirectAction('AuthController@getLogin'); } return App::make('Lio\\Accounts\\UserCreator')->create($this, Session::get('userGithubData')); }
public function imprimeRenta($datos) { $vista = \View::make('pdf.renta', compact('datos'))->render(); $pdf = \App::make('dompdf.wrapper'); $pdf->loadHTML($vista); return $pdf->download('renta.pdf'); }
/** * Execute the console command. * * Return value will be execute code of this command. * So don't return ture/false. It must be integer. * * @return integer Return Code. 0: Terminated successfully. */ public function fire() { $args = array_merge($this->option(), $this->argument()); // I don't want to make extra instance by cascading dependency injection // on constructor for commands from service provider. // So I don't use constructor injection on this command class. $validator = \App::make('Syncle\\Services\\Validators\\SyncleCommandValidator'); $message = $validator->validate($args); // The validator return only error message. if ($message != '') { $this->error($message); return 1; // Presented abnormal termination. } // Get an execute command line or command array. // When no specified --by, default valude is 'default'. See getOptions() method. $commandItems = \Config::get('syncle::DeployMethod.' . $args['by']); // Get default commit message. $commitMessage = $args['message'] == '' ? \Config::get('syncle::DefaultGitMessage') : $args['message']; // Deploy this project. $deployer = \App::make('Syncle\\Services\\Deployers\\Deployer'); $result = $deployer->deploy($commandItems, $args['verbose'], $args['log'], $commitMessage); // Display output. foreach ($deployer->getOutput() as $line) { $this->line($line); } return $result; }
public function entityUrl($entity, $methods) { $appHelper = new libs\AppHelper(); $urls = Link::getMainUrls(); if (in_array($entity, $urls)) { $controller_path = 'Serverfireteam\\Panel\\' . $entity . 'Controller'; } else { $panel_path = \Config::get('panel.controllers'); if (isset($panel_path)) { $controller_path = '\\' . $panel_path . '\\' . $entity . 'Controller'; } else { $controller_path = $appHelper->getNameSpace() . 'Http\\Controllers\\' . $entity . 'Controller'; } } try { $controller = \App::make($controller_path); } catch (\Exception $ex) { throw new \Exception("Can not found the Controller ( {$controller_path} ) "); } if (!method_exists($controller, $methods)) { throw new \Exception('Controller does not implement the CrudController methods!'); } else { return $controller->callAction($methods, array('entity' => $entity)); } }
public function postFoodAreaStore() { $post = Input::all(); $response = array(); $model = App::make("Category"); switch ($post["action"]) { case "create": $data = $post["data"]; $data["parent_code"] = "FOOD_AREA"; $data["level"] = "2"; $response = $this->saveModel($data, $model, Category::$rules, Category::$validatorMessages); break; case "edit": $data = $post["data"]; $data["parent_code"] = "FOOD_AREA"; $data["level"] = "2"; $model = $model->find($post["id"]); $response = $this->saveModel($data, $model, Category::$rules, Category::$validatorMessages); break; case "remove": $ids = $post["id"]; foreach ($ids as $id) { $data = $model->find($id); $data->delete(); } break; } return Response::json($response); }
public function bootstrap() { parent::bootstrap(); $em = \App::make(EntityManager::class); $this->getArtisan()->getHelperSet()->set(new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'db'); $this->getArtisan()->getHelperSet()->set(new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em), 'em'); }
/** * Constructor. * * @param $tables */ public function __construct($tables) { $this->dispatcher = \App::make(Dispatcher::class); $this->tables = is_array($tables) ? $tables : [$tables]; $this->tableList = $this->getTableList(); $this->tablesContent = $this->getTableContent(); }