/** * Get the contents of the migration stub. * * @return string */ protected function getMigrationStub() { $stub = file_get_contents(__DIR__ . '/../Stubs/MetableMigration.stub.php'); $stub = str_replace('{{table}}', $this->argument('table'), $stub); $stub = str_replace('{{class}}', 'Create' . Str::studly($this->argument('table')) . 'Table', $stub); return $stub; }
public function get($type = null) { if ($type) { return $this->{"get" . Str::studly("{$type}-template")}(); } $template = false; if ($this->env->is_404() && ($template = $this->get('404'))) { } elseif ($this->env->is_search() && ($template = $this->get('search'))) { } elseif ($this->env->is_front_page() && ($template = $this->get('front-page'))) { } elseif ($this->env->is_home() && ($template = $this->get('home'))) { } elseif ($this->env->is_post_type_archive() && ($template = $this->get('post-type-archive'))) { } elseif ($this->env->is_tax() && ($template = $this->get('taxonomy'))) { } elseif ($this->env->is_attachment() && ($template = $this->get('attachment'))) { } elseif ($this->env->is_single() && ($template = $this->get('single'))) { } elseif ($this->env->is_page() && ($template = $this->get('page'))) { } elseif ($this->env->is_singular() && ($template = $this->get('singular'))) { } elseif ($this->env->is_category() && ($template = $this->get('category'))) { } elseif ($this->env->is_tag() && ($template = $this->get('tag'))) { } elseif ($this->env->is_author() && ($template = $this->get('author'))) { } elseif ($this->env->is_date() && ($template = $this->get('date'))) { } elseif ($this->env->is_archive() && ($template = $this->get('archive'))) { } elseif ($this->env->is_comments_popup() && ($template = $this->get('comments-popup'))) { } elseif ($this->env->is_paged() && ($template = $this->get('paged'))) { } else { $template = $this->getIndexTemplate(); } return $template; }
/** * Establish a PDO connection based on the configuration. * * @param array $config * @param string $driver * * @return \Illuminate\Database\Connection */ public function make($driver, array $config = []) { if (method_exists($this, $method = "make" . Str::studly($driver) . "Connection")) { return $this->{$method}($config); } throw new InvalidArgumentException("Unsupported connection [{$driver}]"); }
/** * Get the contents of the customer migration stub. * * @return string */ protected function getMigrationStub() { $stub = file_get_contents(__DIR__ . '/../DorellJames/Billing/Stubs/CustomerMigration.stub'); $stub = str_replace('customer_table', $this->argument('table'), $stub); $stub = str_replace('AddCustomerBillingColumnsTo', 'AddCustomerBillingColumnsTo' . Str::studly($this->argument('table')), $stub); return $stub; }
public function logs() { $model_id = Str::studly($this->getTable()); $data_id = $this->id; $logs = Activitylog::where('model_id', $model_id)->where('data_id', $data_id)->orderBy('id', 'desc')->get(); return $logs->toArray(); }
/** * TwoSelectBox constructor. * * @param $name * @param $type * @param Form $parent * @param array $options */ public function __construct($name, $type, Form $parent, array $options) { $options['attr']['extend'] = true; $options['attr']['multiple'] = true; $options['btnSelect'] = array_merge(['class' => 'btn', 'id' => 'btnSelect'], isset($options['btnSelect']) ? $options['btnSelect'] : []); $options['btnUnSelect'] = array_merge(['class' => 'btn', 'id' => 'btnUnSelect'], isset($options['btnUnSelect']) ? $options['btnUnSelect'] : []); $options['container_id'] = Str::studly(Str::slug($name, '_')) . "TwoSelectBoxContainer"; /** Load data from model */ /** @var Model $model */ $model = $options['model']; $primary = $options['primary']; $show = $options['show']; /** Detect I18N */ $locale = \Config::get('app.locale'); $is_i18n = method_exists($model, 'saveI18N'); $query = $is_i18n ? $model::I18N($locale) : $model::query(); /** END **/ if (key_exists('filter', $options) && count($options['filter']) > 0) { foreach ($options['filter'] as $key => $item) { $query->where($key, $item['condition'], $item['value']); } } /** Parse to key-name format {$table}.{$field} */ $keyName = strpos($options['primary'], '.') ? $options['primary'] : (new $model())->getTable() . "." . $options['primary']; $data = $query->select($keyName, $show)->get()->toArray(); /** Fill model data to choice array */ $options['choices'] = array_pluck($data, $show, $primary); /** END */ $options['selected'] = array_get($options, 'value', []); /** END */ $options['selected'] = (array) (isset($options['selected']) ? $options['selected'] : []); parent::__construct($name, $type, $parent, $options); }
public function setAttribute($key, $value) { if ($this->hasCast($key) && method_exists($this, $method = 'set' . Str::studly($this->getCastType($key)) . 'Attribute')) { return $this->{$method}($key, $value); } return parent::setAttribute($key, $value); }
/** * Run migrations for the specified module. * * @param string $slug * @return mixed */ protected function migrate($slug) { $moduleName = Str::studly($slug); if ($this->module->exists($slug)) { $pretend = $this->option('pretend'); $path = $this->getMigrationPath($slug); $this->migrator->run($path, $pretend); // Once the migrator has run we will grab the note output and send it out to // the console screen, since the migrator itself functions without having // any instances of the OutputInterface contract passed into the class. foreach ($this->migrator->getNotes() as $note) { if (!$this->option('quiet')) { $this->output->writeln($note); } } // Finally, if the "seed" option has been given, we will re-run the database // seed task to re-populate the database, which is convenient when adding // a migration and a seed at the same time, as it is only this command. if ($this->option('seed')) { $this->call('module:seed', ['module' => $slug, '--force' => true]); } } else { return $this->error("Module [{$moduleName}] does not exist."); } }
/** * Get the contents of the subscription migration stub. * * @return string */ protected function getMigrationStub() { $stub = file_get_contents(__DIR__ . '/../Mmanos/Billing/Stubs/SubscriptionMigration.stub'); $stub = str_replace('subscription_table', $this->argument('table'), $stub); $stub = str_replace('AddSubscriptionBillingColumnsTo', 'AddSubscriptionBillingColumnsTo' . Str::studly($this->argument('table')), $stub); return $stub; }
private function registerDirectives() { Blade::directive('allowed', function ($expression) { if (Str::startsWith($expression, '(')) { $expression = substr($expression, 1, -1); } return "<?php if (app('rbac')->checkAccess(\\Auth::user(), {$expression})): ?>"; }); if (Config::get('rbac.shortDirectives')) { foreach (Rbac::getRepository() as $name => $item) { $directiveName = $item->type == Item::TYPE_PERMISSION ? 'allowed' : 'is'; $directiveName .= Str::studly(str_replace('.', ' ', $name)); Blade::directive($directiveName, function ($expression) use($name) { $expression = trim($expression, '()'); if (!empty($expression)) { $expression = ', ' . $expression; } return "<?php if (app('rbac')->checkAccess(\\Auth::user(), '{$name}'{$expression})): ?>"; }); } } Blade::directive('endallowed', function ($expression) { return "<?php endif; ?>"; }); }
public function guessModel() { $method = $this->guessRelatedMethod(); $modelName = Str::studly($method); if ($method && Artificer::modelManager()->has($modelName)) { return $modelName; } }
protected function getPluralClassName() { $classPlural = Str::studly($this->argument('resource-plural')); if (is_null($classPlural) || empty($classPlural)) { $classPlural = $this->getSingularClassName() . 's'; } return $classPlural; }
/** * "magic" caller method to simply instantiate field types. * * @param string $type * @param array $arguments * * @access public * @return BaseField */ public function __call($type, array $arguments) { $name = array_shift($arguments); $type = sprintf('\\KraftHaus\\Bauhaus\\Field\\%sField', Str::studly($type)); $field = new $type($name, $this->getAdmin()); $this->fields[$name] = $field; return $field; }
/** * Seed the specified module. * * @parama string $name * @return array */ protected function dbseed($name) { $params = ['--class' => $this->option('class') ? $this->option('class') : Str::studly($name) . 'DatabaseSeeder']; if ($option = $this->option('database')) { $params['--database'] = $option; } $this->call('db:seed', $params); }
/** * Generates a class name by combining the name with the suffix (i.e. Validation) * * @param string $name * * @return string * * @throws \Ricketson\Validation\NotFoundException */ protected function generateClassName($name) { $className = Str::studly($name . $this->config['class_suffix']); if (!class_exists($className)) { throw new NotFoundException(sprintf('The validation class "%s" does not exist.', $className)); } return $className; }
public function hasSetMutator($key) { $method = 'set' . Str::studly($key) . 'Attribute'; if (static::hasMacro($method)) { return true; } return method_exists($this, $method); }
/** * Override original behavior. * * @see \Illuminate\Database\Eloquent\Model::hasSetMutator() * @param $key * @return bool */ public function hasSetMutator($key) { if (isset(static::$externalMethods['set' . Str::studly($key) . 'Attribute'])) { return true; } // Keep parent functionality. return parent::hasSetMutator($key); }
function getAddressCoords($address, $service = null) { if (is_null($service)) { $service = $this->config['coder']; } $method = "getCoordsByAddress" . Str::studly($service); return $this->{$method}($address); }
/** * Execute the console command. * * @return mixed */ public function fire() { $this->container['slug'] = strtolower($this->argument('slug')); $this->container['name'] = Str::studly($this->container['slug']); $this->container['namespace'] = Str::studly($this->container['slug']); $this->displayHeader('make_module_introduction'); $this->stepOne(); }
/** * Transform an attribute. * * @param string $key * @return mixed */ protected function transformAttribute($key) { $method = 'transform' . Str::studly($key) . 'Attribute'; if (method_exists($this, $method)) { return $this->{$method}($key); } return $this->{$key}; }
public function __construct($config) { foreach ($config as $k => $v) { $method = 'set' . Str::studly($k); if (method_exists($this, $method)) { call_user_func([$this, $method], $v); } } }
/** * Set the base constraints on the relation query. * * @return void */ public function addConstraints() { if (static::$constraints && in_array(Str::studly($this->spatialComparison), static::$allowedComparisons)) { $table = $this->getTable(); $this->query->whereNotNull($this->foreignGeometry); $stRelates = sprintf('ST_%3$s(%1$s, %2$s)', $table . '.' . $this->localGeometry, $this->getTable()->getTable() . '.' . $this->foreignGeometry, Str::studly($this->spatialComparison)); $this->query->whereRaw($stRelates); } }
/** * Apply the criteria to the query. * * @param \Illuminate\Database\Eloquent\Builder $builder * * @return void */ public function apply(Builder $builder) { $sortMethod = 'sort' . Str::studly($this->getField()); if (method_exists($builder->getModel(), $sortMethod)) { call_user_func_array([$builder->getModel(), $sortMethod], [$builder, $this->getOrder()]); } else { $builder->orderBy($this->getField(), $this->getOrder()); } }
/** * Set components basic info. */ private function initComponents() { array_walk($this->components, function (&$value, $key) { $name = $dir = Str::studly($key); $path = __DIR__ . "/{$dir}"; $provider = "\\Elektra\\{$dir}\\{$name}ServiceProvider"; $value = compact('dir', 'path', 'provider'); }); }
/** * Resolve a migration instance from a file. * * @param string $file * @return object */ public function resolve($file) { $file = implode('_', array_slice(explode('_', $file), 4)); $class = Str::studly($file); if ($this->module) { $class = $this->module->getNamespace() . '\\Database\\Migrations\\' . $class; } return new $class(); }
/** * Resolve a migration instance from a file. * * @param string $file * @return object */ public function resolve($file) { list($file, $namespace) = $this->parseFileName($file); $class = sprintf('%s%s', $namespace, Str::studly(implode('_', array_slice(explode('_', $file), 4)))); if (!class_exists($class)) { $this->requireFiles(null, [$file]); } return new $class(); }
public function setApiName($name) { $this->_api_name = Pluralizer::singular($name); $this->_collection_name = Str::studly(Str::singular(Str::slug($this->_api_name, " "))); if (!class_exists("AndrewLamers\\Chargify\\" . $this->_collection_name)) { eval("namespace Andrewlamers\\Chargify; class " . $this->_collection_name . " extends \\Andrewlamers\\Chargify\\Fluent {}"); } $this->_collection_name = "Andrewlamers\\Chargify\\" . $this->_collection_name; }
/** * Execute the console command. * * @return mixed */ public function fire() { $name = $this->argument('name'); $modelName = Str::studly($this->argument('name')); $tableName = 'crud_' . Str::lower($name); $this->call('crud:migration', ['name' => $name]); $this->call('crud:model', ['name' => $modelName, '--table' => $tableName]); $this->call('crud:controller', ['name' => $modelName]); $this->call('crud:permission', ['name' => $modelName]); }
/** * Generate content for language file. * * @param string $resource * * @return string */ protected function createFile($resource) { $stub = $this->files->get($this->stubPath('crud/lang.stub')); $resources = Str::plural($resource); $stub = str_replace('DummyResourceNamePlural', $resources, $stub); $stub = str_replace('DummyResourceName', $resource, $stub); $stub = str_replace('DummyResourceStudlyPlural', Str::studly($resources), $stub); $stub = str_replace('DummyResourceStudly', Str::studly($resource), $stub); return $stub; }
/** * Execute the console command. * * @return void */ public function fire() { $table = $this->laravel['config']['queue.failed.table']; $tableClassName = Str::studly($table); $fullPath = $this->createBaseMigration($table); $stub = str_replace(['{{table}}', '{{tableClassName}}'], [$table, $tableClassName], $this->files->get(__DIR__ . '/stubs/failed_jobs.stub')); $this->files->put($fullPath, $stub); $this->info('Migration created successfully!'); $this->composer->dumpAutoloads(); }