sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function applyValue($query, $target, $value, $combineOr = null, $isFirst = false) { // If we're splitting terms, the terms will first be split by whitespace // otherwise the whole search value will treated at a single string. // Array values will always be treated as split string s...
Applies a value directly to a builder object. @param Builder $query @param string $target @param mixed $value @param null|bool $combineOr overrides global value if non-null @param bool $isFirst whether this is the first expression (between brackets) @return mixed
entailment
protected function applyTerm($query, $target, $value, $combineOr = null, $isFirst = false) { $combineOr = ! $isFirst && ($combineOr === null ? $this->combineSplitTermsOr : $combineOr); $combine = $combineOr ? 'or' : 'and'; if (is_array($value)) { return $query->whereIn($target...
Applies a single (potentially) split off value directly to a builder object. @param Builder $query @param string $target @param mixed $value @param null|bool $combineOr @param bool $isFirst whether this is the first expression (between brackets) @return mixed
entailment
public function retrieve(Model $model, $source) { $this->model = $model; if ($this->isTranslated()) { $keys = []; $localeKey = config('translatable.locale_key', 'locale'); foreach ($model->translations as $translation) { /** @var Relation $...
Retrieves current values from a model @param Model $model @param string $source @return mixed
entailment
protected function detachRelatedModelsForOneOrMany($models, Relation $relation) { if ($models instanceof Model) { $models = new Collection([ $models ]); } if ( ! $this->allowDetachingOfOneOrMany() || ! count($models)) { return; } // If models that we...
Detaches models no longer to be related for *One and *Many relations. Note that all models are expected to be of a single class. @param Collection|Model[]|Model $models @param Relation $relation
entailment
protected function getForeignKeyNamesForRelation(Relation $relation) { if ( $relation instanceof BelongsTo || $relation instanceof HasOne || $relation instanceof HasMany || is_a($relation, '\\Znck\\Eloquent\\Relations\\BelongsToThrough', true) ) { ...
Returns the foreign key names for a given relation class. For BelongsToMany, this returns the key to the local model first, the other model second. For Morph relations, this will return the id/key and type column names. For MorphToMany the morph keys are followed by the other foreign key. @param Relation $relation @r...
entailment
protected function hasNullableForeignKeys(Relation $relation, Model $model = null, array $keys = null) { if (null === $keys) { $keys = $this->getForeignKeyNamesForRelation($relation); } if ( ! count($keys)) return false; // Determine the model on which the foreign key i...
Returns whether a relation's related model has nullable foreign keys. @param Relation $relation @param Model $model if the model with the keys should not be resolved, pass it in @param string[]|null $keys if already known, the foreign keys for the relation @return bool
entailment
protected function setForeignKeysToNull(Model $model, Relation $relation, array $keys) { if ( ! count($keys)) return; $key = $this->normalizeForeignKey(head($keys)); $model->{$key} = null; if ( count($keys) > 1 && ( $relation instanceof MorphTo ...
Sets the foreign keys to null on a given model. @param Model $model @param Relation $relation @param string[] $keys
entailment
protected function explicitlyConfiguredForeignKeysNullable() { $nullable = array_get($this->formFieldData->options(), 'nullable_key'); if (null === $nullable) return null; return (bool) $nullable; }
Returns whether the relation's foreign keys were configured nullable. @return bool|null null if the nullabillity of the keys was not configured
entailment
protected function prepareValue($value) { if ($this->hasMutator()) { return call_user_func($this->getMutator(), $value); } elseif ($value && $this->isElementOfDate() && $this->isDateCastable()) { $value = $this->castValueAsDateTime($value); if ($this instanceof Ti...
@param mixed $value @return mixed
entailment
public function getValue() { $value = $this->getValueFromModel(); if (is_null($value)) { return $this->getDefaultValue(); } if ($this->isCastable()) { $value = $this->castValue($value); } return $value; }
{@inheritdoc}
entailment
protected function performStep() { $attributes = []; // Get the columns from the model's table $tableFields = $this->databaseAnalyzer()->getColumns( $this->model()->getTable(), $this->model()->getConnectionName() ); foreach ($tableFields as $field) {...
Performs the analyzer step on the stored model information instance.
entailment
protected function getAttributeCastForColumnType($type, $length = null) { switch ($type) { case 'bool': return AttributeCast::BOOLEAN; case 'tinyint': if ($length === 1) { return AttributeCast::BOOLEAN; } ...
Returns cast enum value for database column type string and length. @param string $type @param null|int $length @return string
entailment
protected function normalizeCastString($cast) { switch ($cast) { case 'bool': case 'boolean': $cast = AttributeCast::BOOLEAN; break; case 'decimal': case 'double': case 'float': case 'real': ...
Normalizes a cast string to enum value if possible. @param string $cast @return string
entailment
public function enrich(ModelInformationInterface $info, $allInformation = null) { $this->info = $info; $class = $this->info->modelClass(); $this->model = new $class; $this->allInfo = $allInformation; $this->performEnrichment(); return $this->info; }
Performs enrichment on model information. Optionally takes all model information known as context. @param ModelInformationInterface|ModelInformation $info @param Collection|ModelInformationInterface[]|ModelInformation[]|null $allInformation @return ModelInformationInterface|ModelInformation
entailment
protected function shouldAttributeBeDisplayedByDefault(ModelAttributeData $attribute, ModelInformationInterface $info) { if (in_array($attribute->type, [ 'text', 'longtext', 'mediumtext', 'blob', 'longblob', 'mediumblob', ])) { return false; } // ...
Returns whether an attribute should be displayed if no user-defined list columns are configured. @param ModelAttributeData $attribute @param ModelInformationInterface|ModelInformation $info @return bool
entailment
public function mapWebRoutes(Router $router) { $router->group( [ 'prefix' => $this->getRoutePrefix(), 'as' => $this->getRouteNamePrefix(), ], function (Router $router) { $controller = $this->getModelWebController(); ...
Generates web routes for the module given a contextual router instance. @param Router $router
entailment
public function mapApiRoutes(Router $router) { $router->group( [ 'prefix' => $this->getRoutePrefix(), 'as' => $this->getRouteNamePrefix(), ], function (Router $router) { $controller = $this->getModelApiController(); ...
Generates API routes for the module given a contextual router instance. @param Router $router
entailment
public function store(Model $model, array $data) { if ( ! config('cms-models.transactions')) { return $this->storeFormFieldValuesForModel($model, $data); } // Perform the whole store process in a transaction DB::beginTransaction(); try { $success = ...
Stores submitted form field data on a model. @param Model $model @param array $data @return bool @throws Exception
entailment
protected function storeFormFieldValuesForModel(Model $model, array $values) { // Prepare field data and strategies /** @var ModelFormFieldDataInterface[]|ModelFormFieldData[] $fields */ /** @var FormFieldStoreStrategyInterface[] $strategies */ $fields = []; $strategies ...
Stores filled in form field data for a model instance. Note that this will persist the model if it is a new instance. @param Model $model @param array $values associative array with form data, should only include actual field data @return bool @throws StrategyApplicationException
entailment
protected function allowedToUseFormFieldData(ModelFormFieldDataInterface $field) { if ( ! $field->adminOnly() && ! count($field->permissions())) { return true; } $auth = $this->core->auth(); if ($field->adminOnly() && ! $auth->admin()) { return false; ...
Returns whether current user has permission to use the form field. @param ModelFormFieldDataInterface $field @return bool
entailment
public function make($strategy) { if ( ! $strategy) { return $this->getDefaultStrategy(); } // If the strategy indicates the FQN of display strategy, // or a classname that can be found in the default strategy name path, use it. if ($strategyClass = $this->resolv...
Makes a show field strategy instance. @param string $strategy @return ShowFieldInterface
entailment
protected function resolveStrategyClass($strategy) { if ( ! str_contains($strategy, '.') && $aliasStrategy = config( 'cms-models.strategies.show.aliases.' . $strategy, config('cms-models.strategies.list.aliases.' . $strategy) ) ) { ...
Resolves strategy assuming it is the class name or FQN of a show field interface implementation or an alias for one. @param string $strategy @return string|false returns full class namespace if it was resolved succesfully
entailment
protected function getValueFromRelationQuery($query) { // Query must be a relation in this case, since we need the related model if ( ! ($query instanceof BelongsToMany)) { throw new UnexpectedValueException("Query must be BelongsToMany Relation instance for " . get_class($this)); ...
Returns the value per relation for a given relation query builder. @param Builder|Relation $query @return mixed|null
entailment
public function performStoreAfter(Model $model, $source, $value) { $relation = $this->resolveModelSource($model, $source); if ( ! ($relation instanceof BelongsToMany)) { throw new UnexpectedValueException("{$source} did not resolve to BelongsToMany relation"); } $relati...
Stores a submitted value on a model, after it has been created (or saved). @param Model $model @param mixed $source @param mixed $value
entailment
protected function convertValueToSyncFormat($value) { if (null === $value) { return []; } $orderColumn = $this->getPivotOrderColumn(); return array_map( function ($position) use ($orderColumn) { return [ $orderColumn => $position ]; ...
Converts submitted value array to sync() format. @param array|null $value @return array associative, keys are related model ids, values update values
entailment
public function descendantFieldKeys(): array { $keys = []; foreach ($this->children() as $key => $node) { if ($node instanceof ModelFormLayoutNodeInterface) { $keys = array_merge($keys, $node->descendantFieldKeys()); continue; } ...
Returns list of keys of form fields that are descendants of this tab. @return string[]
entailment
protected function getUserString() { $user = $this->core->auth()->user(); if ( ! $user) return null; return $user->getUsername(); }
Returns user name for currently logged in user, if known. @return null|string
entailment
protected function performEnrichment() { if ( ! count($this->info->export->columns)) { $this->fillDataForEmpty(); } else { $this->enrichCustomData(); } // Separate strategies may have their own column setups. // If not, the defaults should be copied f...
Performs enrichment.
entailment
protected function fillDataForEmpty() { // Fill export columns if they are empty $columns = []; $foreignKeys = $this->collectForeignKeys(); // Add columns for attributes foreach ($this->info->attributes as $attribute) { if ($attribute->hidden || in_array($attri...
Fills column data if no custom data is set.
entailment
protected function collectForeignKeys() { $keys = []; foreach ($this->info->relations as $relation) { if ( ! in_array( $relation->type, [ RelationType::BELONGS_TO, RelationType::MORPH_TO, RelationType::BELONGS_TO_THROUGH ] )) { ...
Returns list of foreign key attribute names on this model. @return string[]
entailment
protected function enrichCustomData($strategy = null) { // Check filled columns and enrich them as required // Note that these can be either attributes or relations $columns = []; if (null === $strategy) { $columnsOrigin = $this->info->export->columns; } else { ...
Enriches existing user configured data. @param string|null $strategy @throws ModelInformationEnrichmentException
entailment
protected function enrichColumn($key, ModelExportColumnDataInterface $column, array &$columns) { // Check if we can enrich, if we must. if ( ! isset($this->info->attributes[ $key ])) { // if the column data is fully set, no need to enrich if ($this->isExportColumnDataComplet...
Enriches a single export column and saves the data. @param ModelExportColumnDataInterface $column @param string $key @param array $columns by reference, data array to build, updated with enriched data
entailment
protected function makeModelExportColumnDataForAttributeData(ModelAttributeData $attribute) { return new ModelExportColumnData([ 'hide' => false, 'source' => $attribute->name, 'strategy' => $this->determineExportColumnStrategyForAttribute($attribute), ]); ...
Makes data set for export column given attribute data. @param ModelAttributeData $attribute @return ModelExportColumnData
entailment
public function toArray() { return [ 'name' => $this->getName(), 'label' => $this->getLabel(), 'width' => $this->getWidth(), 'fixed' => $this->isFixed(), 'minWidth' => $this->getMinWidth(), 'sortable' => $this->getSortable(...
The column options @return array
entailment
public function getValue() { $value = $this->getModelValue(); if (is_null($value)) { $value = $this->getDefaultValue(); } return $value; }
Get the column value @return string|static
entailment
protected function checkActiveSort($update = true) { $request = request(); if ($update && $request->has('sort')) { $this->activeSort = $request->get('sort'); if ($request->filled('sortdir') && ! empty($request->get('sortdir'))) { $this->activeSortDescending...
Checks and sets the active sort settings. @param bool $update @return $this
entailment
protected function storeActiveSortInSession() { if (null !== $this->activeSortDescending) { $direction = $this->activeSortDescending ? 'desc' : 'asc'; } else { $direction = null; } $this->getListMemory()->setSortData($this->activeSort, $direction); }
Stores the currently active sort settings for the session.
entailment
protected function retrieveActiveSortFromSession() { $sessionSort = $this->getListMemory()->getSortData(); if ( ! is_array($sessionSort)) return; $this->activeSort = array_get($sessionSort, 'column'); $direction = array_get($sessionSort, 'direction'); if (null === $direct...
Retrieves the sort settings from the session and restores them as active.
entailment
protected function getActualSortDirection($column = null) { $column = $column ?: $this->activeSort; if (null !== $this->activeSortDescending) { return $this->activeSortDescending ? 'desc' : 'asc'; } if ( ! isset($this->getModelInformation()->list->columns[$column])) { ...
Returns the sort direction that is actually active, determined by the specified sort direction with a fallback to the default. @param string|null $column @return string asc|desc
entailment
protected function getModelSortCriteria() { $sort = $this->getActualSort(); $info = $this->getModelInformation(); // Sort by orderable strategy if we should and can if ( $info->list->orderable && $sort == $info->list->getOrderableColumn() && ($orderableS...
Returns the active model sorting criteria to apply to the model repository. @return ModelOrderStrategy|false
entailment
protected function applySort() { $sort = $this->getActualSort(); if ( ! $sort) return $this; $criteria = $this->getModelSortCriteria(); if ( ! $criteria) return $this; $this->getModelRepository()->pushCriteria($criteria, CriteriaKey::ORDER); return $this; }
Applies active sorting to model repository. @return $this
entailment
public function render(Model $model, $source) { return implode($this->getSeparator(), array_map('e', $model->tagNames())); }
Renders a display value to print to the list view. @param Model|Taggable $model @param mixed $source source column, method name or value @return string
entailment
protected function performStep() { if ( ! $this->modelHasTrait($this->getListifyTraits())) { return; } /** @var Listify $model */ $model = $this->model(); $this->info->list->orderable = true; $this->info->list->order_strategy = 'listify'; $t...
Performs the analyzer step on the stored model information instance.
entailment
protected function setSortingOrder() { if (null !== $this->info->list->default_sort) { return $this; } if ($this->info->list->orderable && $this->info->list->getOrderableColumn()) { $this->info->list->default_sort = $this->info->list->getOrderableColumn(); } ...
Sets default sorting order, if empty. @return $this
entailment
protected function setReferenceSource() { if (null !== $this->info->reference->source) { return $this; } // No source is set, see if we can find a standard match $matchAttributes = config('cms-models.analyzer.reference.sources', []); foreach ($matchAttri...
Sets default reference source, better than primary key, if possible. @return $this
entailment
protected function setDefaultRowActions() { $actions = $this->info->list->default_action ?: []; if (count($actions)) { return $this; } $addEditAction = config('cms-models.defaults.default-listing-action-edit', false); $addShowAction = config('cms-models.defaults...
Sets default actions, if configured to and none are defined. @return $this
entailment
public function processedRules() { $decorator = $this->getRuleDecorator(); return $decorator->decorate( $this->container->call([$this, 'rules']) ); }
Returns post-processed validation rules. @return array
entailment
protected function failedValidation(Validator $validator) { throw (new ModelValidationException($validator)) ->errorBag($this->errorBag) ->redirectTo($this->getRedirectUrl()); }
{@inheritdoc} @throws \Czim\CmsModels\Exceptions\ModelValidationException
entailment
protected function handlePaperclipAttachments() { // Paperclip / attachment attributes $attachments = $this->detectPaperclipAttachments(); // Make a list of attributes to insert before the paperclip attributes /** @var ModelAttributeData[] $inserts */ $inserts = []; ...
Handles analysis of paperclip attachments. @return $this
entailment
protected function detectPaperclipAttachments() { $model = $this->model(); if ( ! ($model instanceof PaperclippableInterface)) { return []; } $files = $model->getAttachedFiles(); $attachments = []; /** @var PaperclipAttachmentInstance[] $files */ ...
Returns list of paperclip attachments, if the model has any. @return PaperclipAttachmentData[] assoc, keyed by attribute name
entailment
protected function extractPaperclipVariantInfo(PaperclipAttachmentInstance $paperclip, $variant) { $config = $paperclip->getNormalizedConfig(); $variantSteps = array_get($config, "variants.{$variant}", []); $dimensions = array_get($variantSteps, 'resize.dimensions'); $extension = ...
Returns extracted data from the paperclip instance for a variant. @param PaperclipAttachmentInstance $paperclip @param string $variant @return array associative
entailment
protected function insertInArray($array, $key, $value, $beforeKey) { // Find the position of the array $position = array_search($beforeKey, array_keys($array)); // Safeguard: silently append if injected position could not be found if (false === $position) { // @codeCover...
Insert an item into an associative array at the position before a given key. @param array $array @param string $key @param mixed $value @param string $beforeKey @return array
entailment
public function render(Model $model, $source) { return view(static::VIEW, [ 'color' => $this->resolveModelSource($model, $source), ]); }
Renders a display value to print to the list view. @param Model $model @param mixed $source source column, method name or value @return string
entailment
protected function performStep() { // Detect whether the model is translated; if not, skip this step if ( ! $this->modelHasTrait($this->getTranslatableTraits())) { return; } // Model is translated using translatable $this->info->translated = true; ...
Performs the analyzer step on the stored model information instance.
entailment
protected function updateAttributesWithTranslated() { $translationInfo = $this->translationAnalyzer()->analyze($this->model()); $attributes = $this->info['attributes']; // Mark the fillable fields on the translation model foreach ($translationInfo['attributes'] as $key => $attribut...
Updates model information attributes with translated attribute data.
entailment
protected function applyRepositoryContext( ModelRepositoryInterface $repository = null, ModelInformationInterface $information = null ) { $repository = $repository ?: call_user_func([ $this, 'getModelRepository' ]); $information = $information ?: call_user_func([ $this, 'getModelIn...
Applies criteria-based repository context strategies. If repository or information are not given, they are read from standard methods: getModelRepository() and getModelInformation respectively. @param ModelRepositoryInterface|null $repository @param ModelInformationInterface|ModelInformation|null $i...
entailment
public function apply($query, $column, $direction = 'asc') { $direction = $direction === 'desc' ? 'desc' : 'asc'; if ($query instanceof Model) { $query = $query->query(); } $query = $this->applyNullLastQuery($query, $column); return $query->orderBy($column, $di...
Applies the sort to a query/model. @param \Illuminate\Database\Eloquent\Builder $query @param string $column @param string $direction asc|desc @return Builder
entailment
protected function applyNullLastQuery($query, $column) { if ($this->databaseSupportsIf($query)) { $query = $query->orderBy(DB::raw("IF(`{$column}` IS NULL,1,0)")); } return $query; }
Applies logic to query builder to sort null or empty fields last. @param Builder $query @param string $column @return Builder
entailment
public function modules() { $modules = new Collection; // Make meta module $modules->push( $this->makeMetaModuleInstance() ); // Make model modules foreach ($this->repository->getAll() as $modelInformation) { $modules->push( $...
Generates and returns module instances. @return Collection|ModuleInterface[]
entailment
protected function makeModuleInstance(ModelInformationInterface $information) { $modelClass = $information->modelClass(); $module = new ModelModule( app(ModelInformationRepositoryInterface::class), $this->moduleHelper, app(RouteHelperInterface::class), ...
Makes a model module instance for model information. @param ModelInformationInterface|ModelInformation $information @return ModelModule
entailment
public function extend($name, ExtensionInterface $extension) { $this->extensions->put($name, $extension); return $this; }
{@inheritdoc}
entailment
public function getQuery() { $repository = $this->getRepository(); $query = $repository->getQuery(); if ($repository->isRestorable()) { $query->withTrashed(); } $this->apply($query); return $query; }
{@inheritdoc}
entailment
public function orderBy($column, $direction = 'asc') { $this->addApply(function (Builder $query) use ($column, $direction) { $query->orderBy($column, $direction); }); return $this; }
{@inheritdoc}
entailment
public function get($key) { try { $result = $this->bucket->get($this->resolveKey($key)); return $this->getMetaDoc($result); } catch (CouchbaseException $e) { return; } }
{@inheritdoc}
entailment
public function add($key, $value, $minutes = 0): bool { $options = ($minutes === 0) ? [] : ['expiry' => ($minutes * 60)]; try { $this->bucket->insert($this->resolveKey($key), $value, $options); return true; } catch (CouchbaseException $e) { return false; ...
Store an item in the cache if the key doesn't exist. @param string|array $key @param mixed $value @param int $minutes @return bool
entailment
public function put($key, $value, $minutes) { $this->bucket->upsert($this->resolveKey($key), $value, ['expiry' => $minutes * 60]); }
{@inheritdoc}
entailment
public function increment($key, $value = 1) { return $this->bucket ->counter($this->resolveKey($key), $value, ['initial' => abs($value)])->value; }
{@inheritdoc}
entailment
public function decrement($key, $value = 1) { return $this->bucket ->counter($this->resolveKey($key), (0 - abs($value)), ['initial' => (0 - abs($value))])->value; }
{@inheritdoc}
entailment
public function forever($key, $value) { try { $this->bucket->insert($this->resolveKey($key), $value); } catch (CouchbaseException $e) { // bucket->insert when called from resetTag in TagSet can throw CAS exceptions, ignore.\ $this->bucket->upsert($this->resolveKey...
{@inheritdoc}
entailment
public function forget($key) { try { $this->bucket->remove($this->resolveKey($key)); } catch (\Exception $e) { // Ignore exceptions from remove } }
{@inheritdoc}
entailment
public function flush() { $result = $this->bucket->manager()->flush(); if (isset($result['_'])) { throw new FlushException($result); } }
flush bucket. @throws FlushException @codeCoverageIgnore
entailment
public function setBucket(string $bucket, string $password = '', string $serialize = 'php'): CouchbaseStore { $this->bucket = $this->cluster->openBucket($bucket, $password); if ($serialize === 'php') { $this->bucket->setTranscoder('couchbase_php_serialize_encoder', 'couchbase_default_dec...
@param string $bucket @param string $password @param string $serialize @return CouchbaseStore
entailment
private function resolveKey($keys) { if (is_array($keys)) { $result = []; foreach ($keys as $key) { $result[] = $this->prefix . $key; } return $result; } return $this->prefix . $keys; }
@param $keys @return array|string
entailment
protected function getMetaDoc($meta) { if ($meta instanceof \Couchbase\Document) { return $meta->value; } if (is_array($meta)) { $result = []; foreach ($meta as $row) { $result[] = $this->getMetaDoc($row); } return ...
@param $meta @return array|null
entailment
public function lock(string $name, int $seconds = 0): Lock { return new CouchbaseLock($this->bucket, $this->prefix.$name, $seconds); }
Get a lock instance. @param string $name @param int $seconds @return \Illuminate\Contracts\Cache\Lock
entailment
protected function generateExport($path = null) { $temporary = $this->getTemporaryFilePath(); // Create new csv file $resource = fopen($temporary, 'w'); if (false === $resource) { throw new RuntimeException("Failed to open temporary export file '{$temporary}'"); ...
Generates an export, download or local file. @param null|string $path @return mixed @throws Exception
entailment
protected function writeCsvContent($resource) { $columns = $this->exportInfo->columns; $strategies = $this->getColumnStrategyInstances(); $delimiter = $this->getDelimiterSymbol(); $enclosure = $this->getEnclosureSymbol(); $escape = $this->getEscapeSymbol(); /...
Writes CSV content to given file handle resource. @param resource $resource
entailment
protected function initializeDefaultValues() { $defaults = []; $filters = $this->getFilterInformation(); foreach (array_keys($filters) as $key) { $defaults[ $key ] = null; } $this->defaults = $defaults; return $this; }
Sets default values based on model information. @return $this
entailment
public function getElement($name) { $key = $this->getElements()->search(function (ElementInterface $item) use ($name ) { return $item->getName() == $name; }); if ($key === false) { throw new InvalidArgumentException('Not found element'); } ret...
{@inheritdoc}
entailment
public function setModel(Model $model) { $this->model = $model; $this->setElementModel($model); return $this; }
{@inheritdoc}
entailment
public function setElementModel(Model $model) { $this->elements->each(function (ElementInterface $element) use ($model) { //if ($element instanceof WithModel) { $element->setModel($model); //} }); return $this; }
{@inheritdoc}
entailment
public function validate() { Validator::validate( request()->all(), $this->getValidationRules(), $this->getValidationMessages(), $this->getValidationTitles() ); return $this; }
{@inheritdoc}
entailment
public function getValues() { return $this->elements->mapWithKeys(function (ElementInterface $element) { return [ $element->getName() => $element->getValue(), ]; }); }
{@inheritdoc}
entailment
protected function generateExport($path = null) { $temporary = $this->getTemporaryFilePath(); if ( ! app()->bound('excel')) { throw new RuntimeException("Excel exporter strategy expected 'excel' to be bound for IoC"); } /** @var Excel $excel */ $excel = app('exc...
Generates an export, download or local file. @param null|string $path @return mixed @throws Exception
entailment
public function getOptionsModel() { $model = $this->options; if (is_string($model)) { $model = app($model); } if (! ($model instanceof Model)) { throw new InvalidArgumentException( sprintf( 'The %s element[%s] options clas...
Get the options model. @return Model
entailment
protected function getOptionsFromModel() { if (is_null(($label = $this->getOptionsLabelAttribute()))) { throw new InvalidArgumentException( sprintf( 'The %s element[%s] options must set label attribute', $this->getType(), ...
Get the options from model. @return \Illuminate\Support\Collection
entailment
public function hasTable($table) { try { $bucketInfo = $this->connection->openBucket($table)->manager()->info(); if (!is_null($bucketInfo['name'])) { return true; } return true; } catch (Exception $e) { return false; ...
{@inheritdoc}
entailment
public function create($collection, Closure $callback = null) { $blueprint = $this->createBlueprint($collection); $blueprint->create(); sleep(10); if ($callback) { $callback($blueprint); } }
needs administrator password, user @param string $collection @param Closure|null $callback @return void
entailment
public function drop($collection) { $blueprint = $this->createBlueprint($collection); $blueprint->drop(); sleep(10); return true; }
{@inheritdoc}
entailment
protected function createBlueprint($table, Closure $callback = null): Blueprint { $blueprint = new Blueprint($table, $callback); $blueprint->connector($this->connection); return $blueprint; }
{@inheritdoc}
entailment
public function apply($query, $column, $direction = 'asc') { $direction = $direction === 'desc' ? 'desc' : 'asc'; $modelTable = $query->getModel()->getTable(); $modelKey = $query->getModel()->getKeyName(); $query->orderBy("{$modelTable}.{$modelKey}", $direction); return ...
Applies the sort to a query/model. @param \Illuminate\Database\Eloquent\Builder $query @param string $column @param string $direction asc|desc @return Builder
entailment
public function handle() { /** @var \Illuminate\Database\Connection|CouchbaseConnection $connection */ $connection = $this->databaseManager->connection($this->option('database')); if ($connection instanceof CouchbaseConnection) { $bucket = $connection->openBucket($this->argument(...
Execute the console command
entailment
public function key() { if ( ! $this->isTranslated()) { return $this->key; } $parts = explode('.', $this->key); array_splice($parts, $this->localeIndex, 0, $this->getLocalePlaceholder()); return trim(implode('.', $parts), '.'); }
Returns the key in dot notation, with locale placeholder where relevant. @return string|null
entailment
public function prefixKey($prefix) { if (empty($this->key)) { $this->key = $prefix; } else { $this->key = $prefix . '.' . $this->key; } return $this; }
Prefixes the currently set key with a dot-notation parent. The (final) dot (.) should not be included in the prefix string. @param string $prefix @return $this
entailment
public function initialize() { if ($this->isInformationCached()) { $this->information = $this->retrieveInformationFromCache(); } else { $this->information = $this->collector->collect(); } $this->fillModelClassIndex(); $this->initialized = true; ...
Initializes the repository so it may provide model information. @return $this
entailment
public function getByModelClass($class) { $this->checkInitialization(); if ( ! array_key_exists($class, $this->modelClassIndex)) { return false; } return $this->getByKey($this->modelClassIndex[$class]); }
Returns model information by the model's FQN. @param string $class @return ModelInformation|false
entailment
public function writeCache() { $this->getFileSystem()->put($this->getCachePath(), $this->serializedInformationForCache($this->information)); return $this; }
Caches model information. @return $this
entailment
protected function fillModelClassIndex() { $this->modelClassIndex = []; foreach ($this->information as $index => $information) { $this->modelClassIndex[ $information->modelClass() ] = $index; } return $this; }
Populates the index for associated class FQNs with the loaded information. @return $this
entailment
public function getDefaultAction() { // Determine the appliccable action if ( ! $this->default_action) { return null; } $actions = $this->default_action; if ( ! is_array($actions)) { $actions = [ new ModelActionReferenceData([ ...
Returns the default action for list rows. @return ModelActionReferenceDataInterface|null
entailment
public function render(Model $model, $source) { $relation = $this->getActualNestedRelation($model, $source); $count = $this->getCount($relation); if ( ! $count) { return '<span class="relation-count count-empty">&nbsp;</span>'; } if ( ! $this->listColumnData) {...
Renders a display value to print to the list view. @param Model $model @param mixed $source source column, method name or value @return string|View
entailment