本文整理汇总了PHP中app函数的典型用法代码示例。如果您正苦于以下问题:PHP app函数的具体用法?PHP app怎么用?PHP app使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了app函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveIdsToNames
/**
* @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);
}
示例2: fire
/**
* 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');
}
}
示例3: getValidatorFromClass
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;
}
示例4: create
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;
}
示例5: __construct
/**
* Ready up blog repositories.
*/
public function __construct()
{
$this->blogCategoriesRepository = app(CategoriesRepositoryInterface::class);
$this->blogPostsRepository = app(PostsRepositoryInterface::class);
$this->blogTagsRepository = app(TagsRepositoryInterface::class);
$this->callConstructor();
}
示例6: down
/**
* 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');
}
示例7: createMigration
/**
* 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;
}
示例8: signMessage
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);
}
示例9: runCommand
/**
* @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());
}
示例10: __construct
public function __construct()
{
$this->assetManager = app(AssetManager::class);
$this->assetPipeline = app(AssetPipeline::class);
$this->addAssets();
$this->requireDefaultAssets();
}
示例11: getDispatcher
/**
* 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;
}
示例12: doProcessing
/**
* 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();
}
示例13: refreshToken
/**
* 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];
}
示例14: boot
/**
* 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'));
});
}
示例15: handle
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;
}
}