izica/relations-widgets-for-backpack
Composer 安装命令:
composer require izica/relations-widgets-for-backpack
包简介
Widgets for preview model relations in laravel backpack
关键字:
README 文档
README
3.0 Whats new:
- relation_table search input
- relation_table create button with relation attribute reference
- relation_table pagination
Installation
composer require izica/relations-widgets-for-backpack
Screenshots
Features
- use widgets for showing relations in show operation
- show or hide panels or fields by conditions
- build field value by closure
- use dot orm notation for accessing relation fields
Documentation
-
relation_panel
name- name of relationlabel- panel labelbackpack_crud- backpack crud url,buttons(optional) - setfalseto hide all action buttonsbutton_show(optional) - setfalseto hidebutton_edit(optional) - setfalseto hidevisible(optional) - closure for hiding or showing panelfields(optional) - fields array, by default get columns fromfillablein modelname- namelabel- for fieldclosure- use closure instead of name field,visible(optional) - closure for hiding or showing panel
-
relation_table
name- (required) name of relationlabel- panel labelrelation_attribute- (optional) used for passing url parameter name for button_createsearch- (optional)closure, enables search inputper_page- (optional) enables pagination,nullby defaultbackpack_crud- backpack crud url,buttons(optional) - setfalseto hide all action buttonsbutton_create(optional) - setfalseto hidebutton_show(optional) - setfalseto hidebutton_edit(optional) - setfalseto hidebutton_delete(optional) - setfalseto hidevisible(optional) -closurefor hiding or showing panelcolumns(optional) - columnsarray, by default get columns fromfillablein modelname- namelabel- for fieldclosure- useclosureinstead of name field for passing value,
Usage
Relation panel
belongsTo, hasOne
use Backpack\CRUD\app\Library\Widget; protected function setupShowOperation() { Widget::add([ 'type' => 'relation_panel', 'name' => 'account_contact', 'label' => 'Account contact info', 'backpack_crud' => 'accountcontact', 'visible' => function($entry){ return $entry->is_public_person; }, 'buttons' => false, 'fields' => [ [ 'label' => 'Birthdate', 'closure' => function($entry){ return date('d.M.Y', $entry->birthdate); } ], [ 'label' => 'Contact phone', 'name' => 'contact_phone', ], [ 'label' => 'Contact email', 'name' => 'contact_email', ], [ 'label' => 'Address', 'name' => 'address.name', 'visible' => function($entry){ return !!$entry->address; } ], ], ])->to('after_content'); }
Relation table
hasMany
protected function setupShowOperation() { Widget::add([ 'type' => 'relation_table', 'name' => 'order_cargos', 'label' => 'Order cargo list', 'backpack_crud' => 'ordercargo', 'visible' => function($entry){ return $entry->order_cargos->count() > 0; }, 'search' => function ($query, $search) { return $query->where('name', 'like', "%{$search}%"); }, 'relation_attribute' => 'order_id', 'button_create' => true, 'button_delete' => false, 'columns' => [ [ 'label' => 'Type', 'name' => 'order_cargo_type.name', ], [ 'label' => 'Weight', 'name' => 'weight', ], [ 'label' => 'Value, $', 'closure' => function($entry){ return "{$entry->value}$"; } ], ], ])->to('after_content'); }
How to enable creating related model
You need to set:
button_create=>truerelation_attribute=>attribute_name
Next you need to add to relation/select field default value:
CRUD::addField([ 'type' => "relationship", 'name' => 'order', 'default' => $_GET['order_id'] ?? null ]);
izica/relations-widgets-for-backpack 适用场景与选型建议
izica/relations-widgets-for-backpack 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 30.07k 次下载、GitHub Stars 达 29, 最近一次更新时间为 2020 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「addon」 「laravel」 「relations」 「widget」 「widgets」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 izica/relations-widgets-for-backpack 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 izica/relations-widgets-for-backpack 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 izica/relations-widgets-for-backpack 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Plugin for YOURLS. Default tools to use in some laemmi plugins
Dropzone field for Laravel Backpack
This ConcreteCMS/concrete5 addon installs a block type that when added to a page allows you to redirect visitors to this page to another page that you specify or an external URL.
Alfabank REST API integration
统计信息
- 总下载量: 30.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 29
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-08


