mahmoud-mosaad/backpack-fields

为 Backpack Laravel 添加有用的自定义字段。

dev-master 2021-10-22 13:03 UTC

This package is auto-updated.

Last update: 2024-09-22 19:14:37 UTC


README

Latest Version on Packagist Total Downloads

此包为 Backpack for Laravel 管理面板提供了自定义字段类型。使用 _toggle 字段允许管理员以更美观的方式将其他字段作为依赖项切换。使用 _array_ajax 字段添加从数组中选择,而不是仅从 关系 中选择。

创建此包是为了使开发者更容易与 Backpack 社区分享他们的自定义字段。你可以使用此包来获取字段类型,当然。但你也可以分叉它,创建一个 Backpack 扩展。有关如何进行此操作的更多信息,请参阅 Backpack 的扩展文档。

屏幕截图

Select From Array Toggle

安装

通过 Composer

composer require mahmoud-mosaad/backpack-fields

使用方法

在你的自定义 CrudController 中

$this->crud->addField([
    'name' => 'from_place',
    'type'  => 'select_from_array_toggle',
    'label' => 'From Places',
    'options' => [
        1 => 'First',
        2 => 'Second',
        3 => 'Third',
        4 => 'Fourth',
        100 => 'Other',
    ],
    'allows_null' => false,
    'show_when' => [
        100 => [
            'from_place_other'
        ]
    ],
]);

$this->crud->addField([
    'name' => 'from_place_other',
    'label' => trans('backpack::base.other'),
    'type' => 'text',
]);

发布视图。 将这些 blade 拷贝到您的目录中

# Publish Vendor Views to resources (Win CMD)
xcopy .\vendor\mahmoud-mosaad\backpack-fields\src\resources\views\crud\fields .\resources\views\vendor\backpack\crud\fields\

# Publish Vendor Views to resources (Bash)
cp .\vendor\mahmoud-mosaad\backpack-fields\src\resources\views\crud\fields .\resources\views\vendor\backpack\crud\fields\

卸载此包。 由于它只提供你已发布的字段,并且你不再使用这些文件,因此保留包安装没有意义

composer remove mahmoud-mosaad/backpack-fields

致谢

许可证

MIT。有关更多信息,请参阅 许可证文件