scratchuz4k/laravel-dataprovider
最新稳定版本:1.0.0
Composer 安装命令:
composer require scratchuz4k/laravel-dataprovider
包简介
This package allows you to query the db via requests
README 文档
README
This package allows you to filter, sort and include eloquent relations based on a request. The DataProvider used in this package uses Laravel's default Eloquent builder and the Illuminate Request.
composer require scratchuz4k/laravel-dataprovider
Basic usage
Just intanciate the provider and return its get method and you're good to go.
use Scratchuz4k\Laravel\DataProvider; $dataProvider = new DataProvider(Article::class); return $dataProvider->get($request);
Available operators
- equals
- not_equals
- contains
- starts_with
- ends_with
- greater_than
- less_than
- greater_than_or_equal_to
- less_than_or_equal_to
- is_null
Queries Examples
- Basic filter:
/articles? filters[0][column]=id& filters[0][operator]=equals& filters[0][value]=1
- Or filter:
/articles? filters[0][column]=id& filters[0][operator]=equals& filters[0][value]=1& filters[1][column]=id& filters[1][operator]=equals& filters[1][value]=2& filters[1][function]=orWhere
- Including relations:
/article?
with=categories
The relations included should be the relations present in the Model.
- Sorting a query:
/articles? sortOrder=asc& sortBy=id
- Filter relations:
/articles? filters[0][column]=categories.id& filters[0][operator]=equals& filters[0][value]=1
The relations filtered should be the relations present in the Model.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2024-04-01