santigarcor/laravel-vuetable
Composer 安装命令:
composer require santigarcor/laravel-vuetable
包简介
Vuetable laravel backend package
README 文档
README
Laravel Vuetable is the backend component that can work with the Vuetable component.
The latest release requires PHP 7.2.5-7.4 and supports Laravel 5.7, 5.8, 6.* ,7.* and 8.*
| Laravel Vuetable | L5.4 | L5.5 | L5.6 | L5.7 | L5.8 | L6 | L7 | L8 |
|---|---|---|---|---|---|---|---|---|
| < 1.0 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | ❌ | ❌ |
| > 1.0 | ❌ | ❌ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Installation
-
Run the composer require command from your terminal:
composer require "santigarcor/laravel-vuetable" -
If you laravel version not supported the package discovery, set in your
config/app.php:-
In the providers array add:
Vuetable\VuetableServiceProvider::class, -
In the aliases array add:
'Vuetable' => Vuetable\VuetableFacade::class,
-
Usage
Your request to the controller should have this data:
{ sort: '', // column_name|asc or column_name|desc page: 1, per_page: 10, searchable: [ // This array should have the names of the columns in the database ], filter: '' //The text that is going to be used to filter the data }
You can also specify the sorting order using the "order" attribute (required by https://mannyyang.github.io/vuetable-3/ ):
{ sort: '', // column_name order: '', // asc or desc }
So for example lets create the table for the users with their companies. Then in the javascript we should have:
data = { sort: 'users.name|asc', page: 1, per_page: 10, searchable: [ // This means the 'users.name', 'users.email' and 'companies.name' columns can be filtered through the 'filter' attribute in the data. 'users.name', 'users.email', 'companies.name', ] } axios.get('http://url.com/users-with-companies', data)
In Controller we can provide Eloquent:
class UsersDataController extends Controller { public function index() { $query = User::select([ 'users.id', 'users.name', 'users.email', 'companies.name as company', 'companies.company_id' ]) ->leftJoin('companies', 'users.company_id', '=', 'companies.id'); return Vuetable::of($query) ->editColumn('company', function ($user) { if ($user->company) { return $user->company; } return '-'; }) ->addColumn('urls', function ($user) { return [ 'edit' => route('users.edit', $user->id), 'delete' => route('users.destroy', $user->id), ]; }) ->make(); } }
Or Collection
class UsersDataController extends Controller { public function index() { $query = new Collection([ ['name' => 'John Doe', 'email' => 'john@mail.com'], ['name' => 'Jane Doe', 'email' => 'jane@mail.com'], ['name' => 'Test John', 'email' => 'test@mail.com'] ]); return Vuetable::of($query) ->editColumn('name', function ($user) { return Str::lower($user['name']); }) ->addColumn('urls', function ($user) { return [ 'edit' => route('users.edit', $user['id']), 'delete' => route('users.destroy', $user['id']), ]; }) ->make(); } }
This controller is going to return:
{
"current_page": 1,
"from": 1,
"to": 10,
"total": 150,
"per_page": 10,
"last_page": 15,
"first_page_url": "http://url.com/users-with-companies?page=1",
"last_page_url": "http://url.com/users-with-companies?page=15",
"next_page_url": "http://url.com/users-with-companies?page=2",
"prev_page_url": null,
"path": "http://url.com/users-with-companies",
"data": [
{
"id": 1,
"name": "Administrator",
"email": "administrator@app.com",
"company": "-",
"company_id": null,
"urls": {
"edit": "http://url.com//users/1/edit",
"delete": "http://url.com//users/1"
},
},
{
"id": 2,
"name": "Company Administrator",
"email": "company_administrator@app.com",
"company": "-",
"company_id": null,
"urls": {
"edit": "http://url.com//users/2/edit",
"delete": "http://url.com//users/2"
},
...
}
],
}
What does Laravel Vuetable support?
Using the Eloquent Builder you can:
- Filter/Sort by model columns.
- Make joins and filter/sort by them.
- Define the length of the pagination.
- Add columns.
- Edit columns (if the column has a cast defined, it doesn't work).
Using the Collection you can:
- Filter/Sort by model columns.
- Define the length of the pagination.
- Add columns.
- Edit columns.
License
Laravel Vuetable is open-sourced software licensed under the MIT license.
Contributing
Please report any issue you find in the issues page. Pull requests are more than welcome.
santigarcor/laravel-vuetable 适用场景与选型建议
santigarcor/laravel-vuetable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 50.35k 次下载、GitHub Stars 达 27, 最近一次更新时间为 2017 年 10 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「table」 「vue」 「vuetable」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 santigarcor/laravel-vuetable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 santigarcor/laravel-vuetable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 santigarcor/laravel-vuetable 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Plug-ins for DataTables
A component that allows creating responsive HTML tables or lists from data object
Adjacency List’ed Closure Table database design pattern implementation for Laravel. Includes restore of tree
Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.
A simple package to create tables in Discord messages.
Code generation for MPMG projects that use Laravel and VueJs tecnologies.
统计信息
- 总下载量: 50.35k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 27
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-05