snapshot of https://github.com/krayin/laravel-crm.git (2.2, 2026-09-18; blobs > 131072B omitted)
Some checks failed
Admin | Playwright Tests / Admin | Playwright Tests | Shard 1 Of 6 (push) Failing after 37s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 2 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 4 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 6 Of 6 (push) Failing after 6s
Linting Tests / PHP 8.3 test on ubuntu-latest (push) Failing after 5s
CI / PHP 8.3 test on ubuntu-latest (push) Failing after 6s
Skills Consistency / validate-skills (push) Successful in 10s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 3 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 5 Of 6 (push) Failing after 6s

This commit is contained in:
upstream-mirror
2026-09-18 04:37:41 +05:00
commit 135ffdb085
1274 changed files with 144880 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
<?php
namespace Webkul\Core\SystemConfig;
use Illuminate\Support\Collection;
class Item
{
/**
* Create a new Item instance.
*/
public function __construct(
public Collection $children,
public ?array $fields,
public ?string $icon,
public ?string $info,
public string $key,
public string $name,
public ?string $route = null,
public ?int $sort = null
) {}
/**
* Get name of config item.
*/
public function getName(): string
{
return $this->name ?? '';
}
/**
* Format options.
*/
private function formatOptions($options)
{
return is_array($options) ? $options : (is_string($options) ? $options : []);
}
/**
* Get fields of config item.
*/
public function getFields(): Collection
{
return collect($this->fields)->map(function ($field) {
return new ItemField(
item_key: $this->key,
name: $field['name'],
title: $field['title'],
info: $field['info'] ?? null,
type: $field['type'],
depends: $field['depends'] ?? null,
path: $field['path'] ?? null,
validation: $field['validation'] ?? null,
default: $field['default'] ?? null,
channel_based: $field['channel_based'] ?? null,
locale_based: $field['locale_based'] ?? null,
options: $this->formatOptions($field['options'] ?? null),
tinymce: $field['tinymce'] ?? false,
is_visible: true,
);
});
}
/**
* Get name of config item.
*/
public function getInfo(): ?string
{
return $this->info;
}
/**
* Get current route.
*/
public function getRoute(): string
{
return $this->route;
}
/**
* Get the url of the config item.
*/
public function getUrl(): string
{
return route($this->getRoute());
}
/**
* Get the key of the config item.
*/
public function getKey(): string
{
return $this->key;
}
/**
* Get Icon.
*/
public function getIcon(): ?string
{
return $this->icon;
}
/**
* Check weather config item have children or not.
*/
public function haveChildren(): bool
{
return $this->children->isNotEmpty();
}
/**
* Get children of config item.
*/
public function getChildren(): Collection
{
if (! $this->haveChildren()) {
return collect();
}
return $this->children;
}
}

View File

@@ -0,0 +1,244 @@
<?php
namespace Webkul\Core\SystemConfig;
use Illuminate\Support\Str;
class ItemField
{
/**
* Laravel to Vee Validation mappings.
*
* @var array
*/
protected $veeValidateMappings = [
'min' => 'min_value',
];
/**
* Create a new ItemField instance.
*/
public function __construct(
public string $item_key,
public string $name,
public string $title,
public ?string $info,
public string $type,
public ?string $path,
public ?string $validation,
public ?string $depends,
public ?string $default,
public ?bool $channel_based,
public ?bool $locale_based,
public array|string $options,
public bool $is_visible = true,
public bool $tinymce = false,
) {
$this->options = $this->getOptions();
}
/**
* Get name of config item.
*/
public function getName(): ?string
{
return $this->name;
}
/**
* Get info of config item.
*/
public function getInfo(): ?string
{
return $this->info ?? '';
}
/**
* Get title of config item.
*/
public function getTitle(): ?string
{
return $this->title ?? '';
}
/**
* Determine if the field should use TinyMCE.
*/
public function getTinymce(): bool
{
return $this->tinymce;
}
/**
* Get type of config item.
*/
public function getType(): string
{
return $this->type;
}
/**
* Get path of config item.
*/
public function getPath(): ?string
{
return $this->path;
}
/**
* Get item key of config item.
*/
public function getItemKey(): string
{
return $this->item_key;
}
/**
* Get validation of config item.
*/
public function getValidations(): ?string
{
if (empty($this->validation)) {
return '';
}
foreach ($this->veeValidateMappings as $laravelRule => $veeValidateRule) {
$this->validation = str_replace($laravelRule, $veeValidateRule, $this->validation);
}
return $this->validation;
}
/**
* Get depends of config item.
*/
public function getDepends(): ?string
{
return $this->depends;
}
/**
* Get default value of config item.
*/
public function getDefault(): ?string
{
return $this->default;
}
/**
* Get channel based of config item.
*/
public function getChannelBased(): ?bool
{
return $this->channel_based;
}
/**
* Get locale based of config item.
*/
public function getLocaleBased(): ?bool
{
return $this->locale_based;
}
/**
* Get name field for forms in configuration page.
*/
public function getNameKey(): string
{
return $this->item_key.'.'.$this->name;
}
/**
* Check if the field is required.
*/
public function isRequired(): string
{
return Str::contains($this->getValidations(), 'required') ? 'required' : '';
}
/**
* Get options of config item.
*/
public function getOptions(): array
{
if (is_array($this->options)) {
return collect($this->options)->map(fn ($option) => [
'title' => trans($option['title']),
'value' => $option['value'],
])->toArray();
}
return collect($this->getFieldOptions($this->options))->map(fn ($option) => [
'title' => trans($option['title']),
'value' => $option['value'],
])->toArray();
}
/**
* Convert the field to an array.
*/
public function toArray()
{
return [
'name' => $this->getName(),
'title' => $this->getTitle(),
'info' => $this->getInfo(),
'type' => $this->getType(),
'path' => $this->getPath(),
'depends' => $this->getDepends(),
'validation' => $this->getValidations(),
'default' => $this->getDefault(),
'channel_based' => $this->getChannelBased(),
'locale_based' => $this->getLocaleBased(),
'options' => $this->getOptions(),
'item_key' => $this->getItemKey(),
'tinymce' => $this->getTinymce(),
];
}
/**
* Get name field for forms in configuration page.
*
* @param string $key
* @return string
*/
public function getNameField($key = null)
{
if (! $key) {
$key = $this->item_key.'.'.$this->name;
}
$nameField = '';
foreach (explode('.', $key) as $key => $field) {
$nameField .= $key === 0 ? $field : '['.$field.']';
}
return $nameField;
}
/**
* Get depend the field name.
*/
public function getDependFieldName(): string
{
if (empty($depends = $this->getDepends())) {
return '';
}
$dependNameKey = $this->getItemKey().'.'.collect(explode(':', $depends))->first();
return $this->getNameField($dependNameKey);
}
/**
* Returns the select options for the field.
*/
protected function getFieldOptions(string $options): array
{
[$class, $method] = Str::parseCallback($options);
return app($class)->$method();
}
}