codedge / livewire-companion
此包已被废弃,不再维护。未建议替换包。
一个带有可使用Laravel Livewire组件的库。
1.0
2020-01-30 10:57 UTC
Requires
- php: ^7.4
- livewire/livewire: ^0.7.0
- spatie/laravel-collection-macros: ^6.0
This package is auto-updated.
Last update: 2020-05-30 01:06:10 UTC
README
Livewire Companion
Livewire Companion 是基于 Laravel Livewire 的组件集合,可以帮助您快速完成常见任务。
包含的组件
所有组件都使用优秀的 Tailwind CSS。 🚀
当前包含的组件有
- Datatable
- 搜索一列
- 列排序
- 分页
- 页面和总记录的指示器
- 每页项数
- 地图(即将推出)
如何安装
您可以通过 composer 安装此包
$ composer require codedge/livewire-companion
该包将自动注册自己。然后发布资源(配置和模板)
$ php artisan vendor:publish --provider="Codedge\LivewireCompanion\LivewireCompanionServiceProvider"
这将会发布所有模板到 resources/views/vendor/livewire-companion
。您可以根据需要自由修改。
如何使用
Datatables
datatables 组件支持 Eloquent 集合 和 支持集合。
在 app/Http/Livewire/MyTable.php
创建一个新文件
<?php declare(strict_types=1); // ... use Codedge\LivewireCompanion\Components\Datatable; class MyTable extends Datatable { protected $model = User::class; // ... }
Livewire 组件需要继承 Datatable
类。然后确保您按照喜好配置组件
$model
: 指定模型类,必需$perPageOptions
: 可用选项显示每页项数,默认:5, 10, 25
$searchingEnabled
: 启用/禁用搜索,默认:true
$sortingEnabled
: 启用/禁用排序,默认:true
$template
: 覆盖 Datatable 模板路径,默认:vendor.livewire-companion.datatable
贡献
如果您缺少任何组件或想扩展功能以及/或者修复错误 - 欢迎提交 PR。我非常乐意合并。